我创建了一个应用于TubeGeometry的自定义曲线。 X轴上的曲线顶点受鼠标移动的影响,而Z轴是受时间增量影响的简单sin曲线:
CustomSinCurve = THREE.Curve.create(
function ( scale ) {
},
function ( t ) {
var coef = 3 * mousePctX;
var tx = coef * ( Math.sin(( t ) * self.amplitude ));
ty = t * self.neckLength,
tz = Math.sin((t + time) * self.amplitude);
var vertex = new THREE.Vector3(tx, ty, tz).multiplyScalar(self.scale);
return vertex;
}
);
这是按预期工作的,除非鼠标移近中心,管似乎在Y轴上“翻转”90度。预期结果是红线始终面朝上。正如您在下面的工作示例中所看到的,当曲线在X轴上伸直时,绿线会更频繁地朝上。有关为什么会发生这种“翻转”的想法吗?
值得注意的是,在上面的CustomSinCurve函数中,如果“tx”设置为“0”,则绿线朝上,而我希望红线朝上。
这是工作示例:http://dev.cartelle.nl/tubeExample/
此处的完整代码:http://dev.cartelle.nl/tubeExample/js/TubeExample.js
答案 0 :(得分:1)
Inside TubeGeometry.js
//if ( tx <= smallest ) {
//smallest = tx;
//normal.set( 1, 0, 0 );
//}
//if ( ty <= smallest ) {
//smallest = ty;
//normal.set( 0, 1, 0 );
//}
//if ( tz <= smallest ) {
normal.set( 0, 0, 1 );
//}