Я хочу создать NURBS-поверхность, анимированную с помощью Three. js.
Это моя инициализация NURBS:
this.nsControlPoints = [
[
new THREE.Vector4 ( -20, -20, 10, 1 ),
new THREE.Vector4 ( -20, -10, -20, 1 ),
new THREE.Vector4 ( -20, 10, 25, 1 ),
new THREE.Vector4 ( -20, 20, -10, 1 )
],
[
new THREE.Vector4 ( 0, -20, 0, 1 ),
new THREE.Vector4 ( 0, -10, -10, 5 ),
new THREE.Vector4 ( 0, 10, 15, 5 ),
new THREE.Vector4 ( 0, 20, 0, 1 )
],
[
new THREE.Vector4 ( 20, -20, -10, 1 ),
new THREE.Vector4 ( 20, -10, 20, 1 ),
new THREE.Vector4 ( 20, 10, -25, 1 ),
new THREE.Vector4 ( 20, 20, 10, 1 )
]
];
var degree1 = 2;
var degree2 = 3;
var knots1 = [0, 0, 0, 1, 1, 1];
var knots2 = [0, 0, 0, 0, 1, 1, 1, 1];
this.nurbsSurface = new NURBSSurface(degree1, degree2, knots1, knots2, this.nsControlPoints);
var map = new THREE.TextureLoader().load( 'assets/img/tile.jpg' );
map.wrapS = map.wrapT = THREE.RepeatWrapping;
map.anisotropy = 16;
let nurbsSurface = this.nurbsSurface;
let start = this.start;
function getSurfacePoint(u, v, target) {
return nurbsSurface.getPoint(u, v, target);
}
this.geometry = new THREE.ParametricBufferGeometry( getSurfacePoint, 20, 20 );
var material = new THREE.MeshBasicMaterial( { wireframe: true, color: 0x666666, opacity: 1.0 } );
this.objectSurface = new THREE.Mesh( this.geometry, material );
this.objectSurface.position.set( - 200, -100, 0 );
this.objectSurface.rotateX(90);
this.objectSurface.scale.multiplyScalar( 50 );
this.scene.add( this.objectSurface );
И это то, что я пытался сделать анимацию:
...
var position = this.geometry.attributes.position;
position.setXYZ(1, position.x + ( Date.now() - this.start ), position.y + ( Date.now() - this.start ), position.z + ( Date.now() - this.start ));
if(position instanceof THREE.BufferAttribute) {
position.needsUpdate = true;
} else {
position.data.needsUpdate = true;
}
...
this.renderer.render(this.scene, this.camera);
Есть предложения, чтобы сделать это? Я не нашел решения по inte rnet с этой темой.
Заранее спасибо !!!