I’m not sure to understand everything.
the center of gravity of the box will not change depending of its orientation.
So, I guess, you want to simulate a (physics) system where the box is oriented 45degree?
And compute the hooks on the box to get 45degrees?
I understand that center of gravity of the box wont change at an angle.
I want to simulate physics system of the box for following:
Based on mass & angle, box shifts slightly at an angle. In playground link example https://playground.babylonjs.com/#RGJQAF#7, heavy box slightly shifts towards left in reality. This introduces slack in right line and right line needs to adjusted to remove slack from the actual box. I want to be able to simulate this using physics.
Based on physics, calculate location (local center) of box at 45 degree angle. Calculated location shouldn’t give slack in left or right line in reality. Use the location to translate and rotate the box.
Identify slack in right line at an angle. Calculate correct line length (from top point to the hook) without having any slack.
You can do the simulation with 2 fixed bodies (with mass = 0), a box impostor and 2 DistanceJoint. Each distance joint connected to the fixed body and to the box. By changing the pivot point, you can change the length of each joint.
Once you know your pivot point, it seems not too much difficult to simulate, without a physics engine, the behavior of the system. The big interest for a physics engine is collision detection.
Your system looks more like a spring system with 1 constraint (box angle).
You will have to destroy the constraint and create a new one. Physics system are more or less static. You build a system and let it have its own life. If you want to compute a system, then you recreate a new one or you use another method instead of doring iterations.
Do I need to destroy 2 DistanceJoints and create a custom joint? if yes, any reference for (1) creating new constraint and (2) the method for computing system, would be helpful.
just want to know, why does the object fall down after calling “object.rotate()” method in this link : https://playground.babylonjs.com/#RGJQAF#22 ? (press ‘r’ key on rendering view to check it)
object has 2 DistanceJoints assigned with maxDistances.