Just I’m trying to create a simple car with movement controls. I made physic bodies with CANNON ridged vehicle it was okay. and if I try to copy the position changes to the model from cannon (merging the physics body and model) it’s working fine when I’m creating with normal three js mesh but when I’m trying the same thing with a model loaded from a glb file. it’s not syncing with the positions correctly. I tried 2 models both of the models facing the same issue. the car body (physics body) is facing the x-axis, the car model is facing the z-axis and the car model is slightly up from the surface. I don’t know what I did wrong. I’ll attach my code and screenshots with this topic. kindly please help me to fix this issue. just now I’m starting to learn.
Honest to Ogar, I read this like 3 times and still have no idea what is going on - short sentences and interpunction are the unsung heroes of this world
From the parts my questionable Engels allowed me to begrijp:
- Then add / subtract from the positions after syncing but before rendering the next frame. There’s no penalty for doing that (and I’d get used to this practice, sooner or later you’ll cross paths with FBX armature animations - tweaking these rotations manually will become your only hope and friend.)
- Same as above:
// NOTE Sync three object with cannon carModel.position.copy(carBody.position); carModel.quaternion.copy(carBody.quaternion); // NOTE Adjust rotations carModel.rotateY(-Math.PI / 2.0);
Keep in mind that in cannon everything is in world-space coordinates. Cannon doesn’t have parent-children structure like three (the only way to connect bodies is via joins, and that doesn’t involve parent-child matrix updates), so it’s always a good idea to move all your three objects to
scene.children directly - and only then sync position and orientation with their cannon bodies.
- Just move it down.
three js - practice.zip (81.8 KB)
Sorry for the verbal mistakes,
in my perspective, we cannot change the position of the model, even if you made changes it won’t reflect in the output because the position will be updated by the cannon physics engine every second.
I have attached my code here. Kindly help me from here
It should be updated every frame (not every second - otherwise you’ll get jumpy physics, unless you’re rendering at 1fps as well) - and adjusted every frame - hence the code snippet I’ve shown above.
if you really don’t know the solution. don’t reply let others reply. Just you’re trying to act like giving solutions for everyone. It’s waste of time bro @mjurczyk