gpt4 book ai didi

Three.js SplineCurve3 没有圆边,或者 LineCurve3 替换

转载 作者:行者123 更新时间:2023-12-04 04:43:17 26 4
gpt4 key购买 nike

例如,我想创建一个 CurvePath

var spline = new THREE.SplineCurve3([
new THREE.Vector3(0, 0, 0),
new THREE.Vector3(1, 0, 0),
new THREE.Vector3(1, 1, 0),
]);

我将使用(javascript psuedocode)发送一个粒子和路径
var t = 0;

function update(){
t = t + 0.05;
particle.position = spline.getPointAt(t)
}

但是我希望样条曲线不要在形状的边缘创建软弯曲,因此对于上面的形状,粒子将在点 (1, 0, 0) 处以直角转动.

我知道这应该在 LineCurve3 中实现或其他东西,但对于除 SplineCurve3 之外的所有其他曲线, getPoint()未实现。

我正在使用三个 r59。

最佳答案

编辑:THREE.Curve.create()已被弃用。见 this answer为了遵循新的模式。

要创建您自己的曲线类,THREE.Curve 的子类,这是要遵循的模式:

MyCurve = THREE.Curve.create(

// define the constructor (args optional)
function( points, s ) {

this.points = points;
this.myProperty = s; // add a property if you want

},

// define the getPoint() function
function( t ) {

return new THREE.Vector3( x, y, z ); // flesh this out

}

);

在您的情况下,您可以复制 SplineCurve3 -- 您只需要更改 getPoint()功能。为此,您可以替换以下内容:
    v.x = THREE.Curve.Utils.interpolate(pt0.x, pt1.x, pt2.x, pt3.x, weight);
v.y = THREE.Curve.Utils.interpolate(pt0.y, pt1.y, pt2.y, pt3.y, weight);
v.z = THREE.Curve.Utils.interpolate(pt0.z, pt1.z, pt2.z, pt3.z, weight);

使用简单的线性插值:
    v.copy( pt1 ).lerp( pt2, weight );

三.js r.60

关于Three.js SplineCurve3 没有圆边,或者 LineCurve3 替换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18578249/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com