Hello, how do I instantiate Vec3 in the top of Scripts? I might have touched upon this area before, but I can’t find the topic [this might end with reference to that one, eventually]
This doesn’t work:
ShapePicker.attributes.add(“eList”, {type: “pc.Vec3”});
This doesn’t work either:
ShapePicker.attributes.add(“eList”, {type: “Vec3”});
The API documentation has a list of types https://developer.playcanvas.com/en/api/pc.ScriptAttributes.html
vec3
is what you are looking for here.
great … it is in the detail
Note to outsiders: as there is a little counter-intuitive deviation:
YauStar is right, but this is also taken from the Camera Path tutorial example:
this.lookAt = new pc.Vec3();
This is different as that’s a class type. The attributes systems is passing a string that represents the class type of the attribute you are declaring. In the engine code, it has a mapping from string to code logic that creates an instance of the type which you can see here: https://github.com/playcanvas/engine/blob/d27a44b6d732c0f1bab94ef5126050db16a1d914/src/script/script.js#L75