Hi,
I prepared two playgrounds.
First works as I need it to. When I rotate the arm joint, whole lever rotates. You can change the value of ROTATION constant and hit play to see, that whole thing rotates.
However in the second example, you can see that the joint rotates, but the lever stays still.
Is there I can do to make the whole thing rotate without implementing the rotate() function, only using the NME?
Thank you.
Hello!
My impression is that it would not be possible, because, when the skeleton matrices are passed from the CPU to the GPU, the rotation in the NME hasn’t been added yet
But maybe there is some way I’m not aware of. Let’s ping @bghgary to confirm.
2 Likes
I’m OOF. Might be good to ping someone else or we’ll have to wait until I’m back next week.
To be clear: you want to update the material to update the world matrix at rendering time?
User uploads glb model. The materials of every mesh are set to default node material. User then can setup his simulations/animations in the nme. After those are set up, he chooses which input blocks will be receiving values in the loop. For example, he will setup a rotation using Rotate2D block, which will have a float named “rpm” as its input. Then during the simulation, value of the block rpm is updated according to the simulation data. It also work with positions using the Matrix input, but in this example, where other meshes are chained to the arm, the rotation does not distribute to the others, therefore doesn’t work for my usecase.
As I’m still fairly new to the BJS, I rather provided whole usecase, but I think the simple answer would be yes.
This is not possible to do as you mentioned.
NME only controls the way things are rendered so basically the color of the pixels on screen but it does not impact any other element rendered in the same scene. It is only a material of a mesh.
What you want is changing the mesh position/transforms themselves.
In general to achieve this I would advise to create your own “configurator” BabylonJS and WebGL 3D configurators to control the experience end to end.
2 Likes
thank you for the parents and pivots link. i tried it in this playground but it doesnt seem to work for my problem.
not the correct angle but I hope you will get what I meant:
glb rotation chain 2 | Babylon.js Playground (babylonjs.com)
1 Like
okay, so setting the rotationQuaternion to null allows me to use .rotation accessor instead of .rotate() method, which could be gamechanger for me, but it displaces the arm. as per your playground example.
but if i leave rotationQuaternion undefined, as it is by default, i can no longer manipulate the rotation via the accessor, as this:
scene.registerBeforeRender(( ) => {
arm.rotation.y += 1
});
doesnt move the arm.
is there a middleground, where the arm wouldn’t get displaced, but i could still use the .rotation.x/y/z accessor?
Using the doc from @Deltakosh about partenting and pivot you could add a transform node as pivot https://playground.babylonjs.com/#BTXEEK#4
1 Like
Thank you very much all. I learned a lot from all your answers.