Ok, what the heck, I wandered off-topic last post, let’s do it once more.
https://playground.babylonjs.com/index.html#RLKVFF#113
Back to a motorEnabled hinge joint on bounding-boxed leg1 (see line 168).
All the leg1 motor fun is happening at lines 488-508. I have included 3 different ways to run joint1 motor (to lift leg1 - after 3 seconds).
Now, I need this ‘motorized landing-gear-folding/unfolding’… to happen real slow. You’ll notice that all 3 methods of motor-running… use 0.4 motorSpeed. Two of the three methods use a motor maxForce of 50000. The last way… the pure-native way, uses maxForce = 3 (and minForce = -3).
Leg1 has a mass of .3… fairly insignificant weight.
Activate/disable various motor-running ways (and then re-run)… but notice that NONE of them… has enough maxForce… to completely lift leg1… to vertical and beyond. Not until you increase the motorSpeed to about 0.6… does the motor have enough maxForce to fully lift the leg.
No matter if maxForce is set to 3 or set to 50000, the motor cannot completely lift the leg… when motor speed is 0.4 or below.
For the actual project, I likely need motor speed around 0.2… and NO motor slippage/weakness.
So, I got problems. It’s likely that I don’t understand motor maxForce… but… according to what I’m seeing right now… maxForce is just “NOT pulling its weight”. Ideas welcome.
Sorry for off-topic… but not really. I don’t know where (on the forum) to chronicle my on-going projects… to share what I learn. So, I grab every sneaky opportunity I can find… like at the bottom of a bugs thread.
It seems (via some tests)… that I can attach springs to all leg-segments (only 1 segment so far)… and then animate their mainPivot locations and spring length/restLengths… to simulate multiple hinge-motors… unfolding a multi-segment landing gear leg. It is like using multiple invisible springs… as if they were puppet strings. But motors would be easier… and cooler, I suspect. For this project, the motors need to be super-slow, and very powerful… and so far… I have failed to fig how to do that.
It is likely that springs and motors don’t mix real well. Motors need to free-wheel and not be held-back by spring tensions. So, likely, during landing gear un-fold, there would not be springs on any bodies… so the motors can work smoothly. Then, after all unfold-motors finish, carefully add springs between all leg segment (bones), with precisely-set pivotpoints and restLengths… so the landing gear can become impact-“bouncy”… in the way we all love so much.
What we REALLY need… is a “springy motor”… it acts like a hinge-spring when it isn’t running… with all the delicious spring settings… like stiffness, damping, frequency, whatever. SpringyMotorEnabledHingeJoint v1.0 YUM!!! sigh.
Another way… use standard animation on non-physics leg-mesh, and then add physics after they are finished unfolding (deploying). But… in doing that… we lose something. Pretend we’re coming-in for a landing a bit too fast (descent-wise), and the landing gear hasn’t finished deploying… when you hit the landing pad. POOM! We want that accident to look physics-yummy, right? You bet. Gotta have physics active on the landing gear pieces… when we kiss the concrete. (if possible)
And, I HOPE there is a way to know WHEN to shut-off the motor… when the leg-segment/motor reaches a certain angle/rotation. I don’t see an easy way to do that… in CannonJS, either. OimoJS motors have .upperLimit and .lowerLimit values (set in degrees, I believe).