有没有办法加快我的光线投射代码?

时间:2015-03-13 23:39:32

标签: javascript three.js

我在three.js中创建了一个球体,其表面上有大约140个圆圈。

Have a look here if you like!

通过点击或触摸圆圈,用户可以更改其颜色。

虽然它在移动设备上有点滞后 - 有没有办法优化以下代码?

function onMouseDown( e ) {


            mouseVector.x = 2 * (e.clientX / (window.innerWidth*0.8)) - 1;
            mouseVector.y = 1 - 2 * ( e.clientY / window.innerHeight );
            raycaster.setFromCamera( mouseVector, camera );

            var intersects = raycaster.intersectObjects( circles );

            if ( intersects.length > 0 ) {

                var intersect = intersects[ 0 ];
                pickedColor=parseInt(document.getElementById("color").value.replace('#', '0x'));

                intersect.object.material.color = new THREE.Color( pickedColor );
                render(); 


            }

        }

0 个答案:

没有答案