【发布时间】:2014-03-05 05:20:59
【问题描述】:
我目前正在为业余视频游戏开发 3D 引擎,我想为他添加大量功能以获得最佳性能和游戏玩法。但是我遇到了严重的问题,无法使用 lod 网格获得“点击事件”。
对于“lod”部分,目前没有问题,他已经整合,但我没有找到解决方案来应用他的例子:
https://stackoverflow.com/a/12808987/3379444
我是否必须单独推动“lod”对象或每个网格?
我的代码的一部分:
var i, j, mesh, lod;
for ( j = 0; j <= 42; j++) {
lod = new THREE.LOD();
//Here, it's just var for place my mesh into a circle
rayonSysteme = Math.floor(Math.random() * 10000) + 2500;
angleSysteme = Math.random() * 360;
for ( i = 0; i < geometry.length; i ++ ) {
mesh = new THREE.Mesh( geometry[ i ][ 0 ], material );
mesh.scale.set( 1.5, 1.5, 1.5 );
mesh.updateMatrix();
mesh.matrixAutoUpdate = false;
//Callback here ?
mesh.callback = function() { console.log( this.name ); }
lod.addLevel( mesh, geometry[ i ][ 1 ] );
}
lod.position.x = rayonSysteme * Math.cos(angleSysteme);
lod.position.y = Math.floor(Math.random() * 1000)-500;
lod.position.z = rayonSysteme * Math.sin(angleSysteme);
//Or here ?
lod.updateMatrix();
lod.matrixAutoUpdate = false;
gravity = drawCircle("XZ", 64, 500, 360);
gravity.position.x = lod.position.x;
gravity.position.y = lod.position.y;
gravity.position.z = lod.position.z;
scene.add( lod );
//objects.push( lod );
scene.add( gravity );
};
【问题讨论】:
-
你能举一个非常简单的活生生的例子来演示这个问题吗?
-
我的主要工作区在这里:lesfougeresdelulu.com/Moteur3D 这是我试图让我的引擎尽可能清洁的地方(但它现在仍然是新手的魔法)。在这里,我尝试了 mrdoob 的建议:lesfougeresdelulu.com/Moteur3D/save2.html(球在左右两边,我没有更改生成代码,所以它是随机的)我的目标是在主代码上获得这个功能,但是它目前仍在工作中。
标签: three.js