У меня есть сфера kinemati c, движущаяся по осям x и z, но моя сфера движется без вращения, как я могу вращать свою сферу, когда она движется?
updateBallMove
метод:
let scalingFactor = startVelocity;
let translateFactor = tmpPos.set(ballObject.move.x, ballObject.move.y, ballObject.move.z);
translateFactor.multiplyScalar(scalingFactor);
ballObject.translateX(translateFactor.x);
ballObject.translateY(translateFactor.y);
ballObject.translateZ(translateFactor.z);
ballObject.getWorldPosition(tmpPos);
ballObject.getWorldQuaternion(tmpQuat);
let physicsBody = ballObject.userData.physicsBody;
let ms = physicsBody.getMotionState();
if ( ms ) {
ammoTmpPos.setValue(tmpPos.x, tmpPos.y, tmpPos.z);
ammoTmpQuat.setValue( tmpQuat.x, tmpQuat.y, tmpQuat.z, tmpQuat.w);
tmpTrans.setIdentity();
tmpTrans.setOrigin( ammoTmpPos );
tmpTrans.setRotation( ammoTmpQuat );
ms.setWorldTransform(tmpTrans);
}
let angVel = ballObject.getAngularVelocity();
ballObject.userData.setAngularVelocity( new Ammo.btVector3( angVel.x, angVel.y, angVel.z ));
}
РЕДАКТИРОВАТЬ: я пытался с angularVelocity, но я получаю TypeError: ballObject.getAngularVelocity is not a function