-
Notifications
You must be signed in to change notification settings - Fork 25
Description
Make a stack of objects all set to be dynamic, and watch them vibrate against each other and eventually fall over.
It turns out that through a happy accident I found a solution to this: Turning on dynamic mode by turning off kinematic mode without changing anything else. e.g.
var my_obj = SimObj.make_object3d({name: "my_object3d", parent: "scene", geometry: "Box",
scale: [0.2, 0.2, 0.2], position: [0.0, 0.3, 0.1], orientation: [0.0, 0.0, 0.0],
material: "MeshNormal", color: [1, 1, 1],
wireframe: false, is_dynamic: false, mass: 1
})
my_obj.userData.physObj.kinematic = falseThis gives you an object that is dynamic, but doesn't vibrate excessively.
After looking about a bit in the code, it appears that this routine
https://github.com/cfry/dde/blob/dde4/src/simulator/physicsObject.js#L757
is setting the mass of the object to ZERO! Which, I'm pretty sure, is what makes it shake. Given some mass, they settle down. I'm not sure about the other flags:
.setActivationState.setCollisionFlags
As those don't seem to be required, but maybe they make the difference?
More experimentation is needed. E.g. replacing the code for
PhysicsObject.makeKinematic()andPhysicsObject.makeDynamic()
with version which don't change the mass.