@@ -128,7 +128,7 @@ const hingeJoint = {
128128 // bullet's hinge motor clamp is an impulse per simulation step, so scale the torque by
129129 // the fixed timestep
130130 const maxImpulse = joint . maxMotorForce * joint . system . app . systems . rigidbody . fixedTimeStep ;
131- joint . _constraint . enableAngularMotor ( joint . enableMotor , joint . motorSpeed * math . DEG_TO_RAD , maxImpulse ) ;
131+ joint . _constraint . enableAngularMotor ( joint . maxMotorForce > 0 , joint . motorSpeed * math . DEG_TO_RAD , maxImpulse ) ;
132132 }
133133} ;
134134
@@ -157,7 +157,7 @@ const sliderJoint = {
157157
158158 updateMotor ( joint ) {
159159 const constraint = joint . _constraint ;
160- constraint . setPoweredLinMotor ( joint . enableMotor ) ;
160+ constraint . setPoweredLinMotor ( joint . maxMotorForce > 0 ) ;
161161 constraint . setTargetLinMotorVelocity ( joint . motorSpeed ) ;
162162 constraint . setMaxLinMotorForce ( joint . maxMotorForce ) ;
163163 }
@@ -352,9 +352,6 @@ class JointComponent extends Component {
352352 /** @private */
353353 _limits = new Vec2 ( - 45 , 45 ) ;
354354
355- /** @private */
356- _enableMotor = false ;
357-
358355 /** @private */
359356 _motorSpeed = 0 ;
360357
@@ -680,32 +677,11 @@ class JointComponent extends Component {
680677 }
681678
682679 /**
683- * Sets whether the joint's motor is enabled. The motor drives a hinge joint's rotation or a
684- * slider joint's translation towards {@link motorSpeed}, applying up to
685- * {@link maxMotorForce}. Not used by other joint types. Defaults to false.
686- *
687- * @type {boolean }
688- */
689- set enableMotor ( arg ) {
690- if ( this . _enableMotor !== arg ) {
691- this . _enableMotor = arg ;
692- this . _updateMotor ( ) ;
693- }
694- }
695-
696- /**
697- * Gets whether the joint's motor is enabled.
698- *
699- * @type {boolean }
700- */
701- get enableMotor ( ) {
702- return this . _enableMotor ;
703- }
704-
705- /**
706- * Sets the target speed of the joint's motor. For hinge joints, this is an angular speed in
707- * degrees per second. For slider joints, this is a linear speed in meters per second. Only
708- * used when {@link enableMotor} is true. Defaults to 0.
680+ * Sets the target speed the motor drives towards. For hinge joints, this is an angular speed
681+ * in degrees per second; for slider joints, a linear speed in meters per second. The motor is
682+ * active only while {@link maxMotorForce} is greater than 0; with a target speed of 0 and a
683+ * positive force the motor acts as a brake, holding the joint at rest. Only used by hinge and
684+ * slider joints. Defaults to 0.
709685 *
710686 * @type {number }
711687 */
@@ -717,7 +693,7 @@ class JointComponent extends Component {
717693 }
718694
719695 /**
720- * Gets the target speed of the joint's motor.
696+ * Gets the target speed the motor drives towards .
721697 *
722698 * @type {number }
723699 */
@@ -726,9 +702,10 @@ class JointComponent extends Component {
726702 }
727703
728704 /**
729- * Sets the maximum force the joint's motor can apply to reach {@link motorSpeed}. For hinge
730- * joints, this is a torque in Newton meters. For slider joints, this is a force in Newtons.
731- * Only used when {@link enableMotor} is true. Defaults to 0.
705+ * Sets the maximum force the motor can apply to reach {@link motorSpeed}. For hinge joints,
706+ * this is a torque in Newton meters; for slider joints, a force in Newtons. The motor is
707+ * disabled while this is 0, so set it greater than 0 to engage the motor. Only used by hinge
708+ * and slider joints. Defaults to 0.
732709 *
733710 * @type {number }
734711 */
0 commit comments