three.jsx3d

Is it possible to name rotations/joints in threejs and how is it possible to set them?


I am doing a bit of work with threejs. And now just wondering if it was possible to name rotations or joints.

So it seems possible to write code like:

arm.rotateZ( 180 ).name="ARM_ANGLE";

But then how does one subsequently access and set the same rotation?

I know in x3d it is possible to do this, so was thinking it would be possible to do as well in threejs. In x3d, one can define a reference as:

<Transform DEF="ArmAngle" rotation="0 0 1 3.19">

And then later define a route to reference it like:

<ROUTE fromNode='spinarm' fromField='value_changed' toNode='ArmAngle' toField='set_rotation'></ROUTE>

Solution

  • What you are describing sounds like animation keys or transform key frames.

    You can define these in a modeller like Blender and export them or generate them programatically.

    But generally, what you are describing from x3d would have to be a layer built on top of three if you really want that style of interface, but honestly, it's pretty straightforward to use the scene graph style of manipulation.. i.e. finding an object and setting its position and rotation.. OR defining an animation in a modeller and then calling that animation. The advantage of using animations is that you can then blend between them.

    You CAN name Objects in three.. so for instance you could name your arm.. and then find it using scene.getObjectByName("arm"). getObjectByName is a method of all Object3Ds.