0
Answered

Rotation mesh

awardstudios 9 months ago updated by Vitaly Ovchinnikov 9 months ago 1

Hi Vitaly thank you for your support; i have last answer (i promise) :-)... i have camera rotation with script, i need to rotate one mesh called “pen” inside to the other way on looping…Can be possibile?

Best regards

Stefano Di Lorenzi

Answer

Answer
Answered

As long as you have the script rotating the camera from our tutorial, you can extend it with some extra lines to rotate other objects. See here for javascript API Koru provides: https://boxshot.com/support/koru-help/dev_api.html

You should already have Koru object in koru variable, so the next step is to find the node to rotate. Then you can setup its rotation angles depending on current time. The code could be something like that:

var nodes = koru.root.getNodesByName("my-node");
if (nodes.length > 0)
{
    var node = nodes[0];
    node.rotation = vec3(0, 0, t);
}


We get all the nodes named "my-node", then we check that we've got anything. Then we take the first node we got and adjust its rotation property with three-angles vector. We use t (time) variable for the third axis which should give us a rotation around the vertical axis.

Answer
Answered

As long as you have the script rotating the camera from our tutorial, you can extend it with some extra lines to rotate other objects. See here for javascript API Koru provides: https://boxshot.com/support/koru-help/dev_api.html

You should already have Koru object in koru variable, so the next step is to find the node to rotate. Then you can setup its rotation angles depending on current time. The code could be something like that:

var nodes = koru.root.getNodesByName("my-node");
if (nodes.length > 0)
{
    var node = nodes[0];
    node.rotation = vec3(0, 0, t);
}


We get all the nodes named "my-node", then we check that we've got anything. Then we take the first node we got and adjust its rotation property with three-angles vector. We use t (time) variable for the third axis which should give us a rotation around the vertical axis.