Three.js-鼠标拖尾
作者:互联网
var spheres = [];
var clock;
...
clock = new THREE.Clock();
var sphereGeometry = new THREE.SphereBufferGeometry( 0.1, 32, 32 );
var sphereMaterial = new THREE.MeshBasicMaterial( { color: 0xff0000 } );
for ( var i = 0; i < 40; i ++ ) {
var sphere = new THREE.Mesh( sphereGeometry, sphereMaterial );
scene.add( sphere );
spheres.push( sphere );
}
...
//默认1,射线点的临界值(超出对象的最大范围)
raycaster.params.Points.threshold = 0.1;
...
var toggle = 0;
function render(){
if ( toggle > 0.02 && intersection !== null ) {
spheres[ spheresIndex ].position.copy( intersection.point );
spheres[ spheresIndex ].scale.set( 1, 1, 1 );
spheresIndex = ( spheresIndex + 1 ) % spheres.length;
toggle = 0;
}
for ( var i = 0; i < spheres.length; i ++ ) {
var sphere = spheres[ i ];
sphere.scale.multiplyScalar( 0.98 );
sphere.scale.clampScalar( 0.01, 1 );
}
toggle += clock.getDelta();
}
标签:sphere,Three,js,spheres,toggle,var,new,THREE,拖尾 来源: https://blog.csdn.net/u013270347/article/details/89362045