Three.JS Object following a spline path - rotation / tanget issues & constant speed issue

橙三吉。 提交于 2019-11-28 07:49:55

To maintain a constant speed, you use .getPointAt( t ) instead of .getPoint( t ).

To get the box to remain tangent to the curve, you follow the same logic as explained in the answer to Orient object's rotation to a spline point tangent in THREE.JS.

    box.position.copy( spline.getPointAt(counter) );

    tangent = spline.getTangentAt(counter).normalize();

    axis.crossVectors( up, tangent ).normalize();

    var radians = Math.acos( up.dot( tangent ) );

    box.quaternion.setFromAxisAngle( axis, radians );

EDIT: Updated fiddle: http://jsfiddle.net/qGPTT/509/

three.js r.88

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!