simplified version by waveplayz
#1167420026291245086 message
use generateCurve(vectors, numPoints)
numPoints: number of point between each vector (vectors[i] and vectors[i+1])
vectors: array of vectors
||example:
const vec = [{x:-96 ,y:-59 ,z: 218},{x:-104,y: -59,z: 224},{x:-111,y: -59,z: 215},{x:-119,y: -59,z: 224}]
const pointes = generateCurve(vec, 20)
for(let point of pointes){
player.dimension.spawnParticle("mba:line", point)
}
```||
code:
```js
function Vector3(x, y, z) {
this.x = x;
this.y = y;
this.z = z;
}
function generateCurve(vectors, numPoints) {
let curve = [];
for (let i = 0; i < vectors.length - 1; i++) {
for (let j = 0; j < numPoints; j++) {
let t = j / numPoints;
let t2 = t * t;
let t3 = t2 * t;
let v0 = vectors[i - 1] || vectors[i];
let v1 = vectors[i];
let v2 = vectors[i + 1] || vectors[i];
let v3 = vectors[i + 2] || vectors[i + 1] || vectors[i];
let x = 0.5 * ((2 * v1.x) + (-v0.x + v2.x) * t +
(2 * v0.x - 5 * v1.x + 4 * v2.x - v3.x) * t2 +
(-v0.x + 3 * v1.x - 3 * v2.x + v3.x) * t3);
let y = 0.5 * ((2 * v1.y) + (-v0.y + v2.y) * t +
(2 * v0.y - 5 * v1.y + 4 * v2.y - v3.y) * t2 +
(-v0.y + 3 * v1.y - 3 * v2.y + v3.y) * t3);
let z = 0.5 * ((2 * v1.z) + (-v0.z + v2.z) * t +
(2 * v0.z - 5 * v1.z + 4 * v2.z - v3.z) * t2 +
(-v0.z + 3 * v1.z - 3 * v2.z + v3.z) * t3);
curve.push(new Vector3(x, y, z));
}
}
return curve;
}