我是三个人。 我正在玩这个样本 http://threejs.org/examples/css3d_periodictable.html
我想知道点击某个特定元素的时间,看到几个样本并添加下面的代码 在函数内部设置断点,即使单击元素内部,intersects.length也始终为0。 请帮忙!我错过了什么? 提前致谢
function onDocumentMouseDown( event ) {
event.preventDefault();
controls.enabled = true;
mouse.x = ( event.clientX / window.innerWidth ) * 2 - 1;
mouse.y = - ( event.clientY / window.innerHeight ) * 2 + 1;
var vector = new THREE.Vector3( mouse.x, mouse.y, 0.5 );
//var vector = new THREE.Vector3( ( event.clientX / window.innerWidth ) * 2 - 1, - ( event.clientY / window.innerHeight ) * 2 + 1, 0.5 );
projector.unprojectVector( vector, camera );
var raycaster = new THREE.Raycaster( camera.position, vector.sub( camera.position ).normalize() );
var intersects = raycaster.intersectObjects( objects,true );
if ( intersects.length > 0 ) {
intersects[ 0 ].object.material.color.setHex( Math.random() * 0xffffff );
var particle = new THREE.Particle( particleMaterial );
particle.position = intersects[ 0 ].point;
particle.scale.x = particle.scale.y = 8;
scene.add( particle );
}
}
答案 0 :(得分:0)
Raycaster不适用于css3Drenderer。 只需使用元素onclick事件