我正在尝试做一个简单的减去两个网格,这是(假设)在CSG中生成的,然后我将它们转换为三个网格,从该几何图形创建一个带有网格的对象。但当我尝试将其显示在屏幕上时,什么也没有显示出来。我通过运行已知可用的CSG测试程序检查了我的库,所以看起来没问题。
所以我一定是错过了一些东西。这里有一个指向整个短程序列表的链接。如果你看到我遗漏了任何关键的代码,我会非常感激知道它是什么,因为我感到困惑。
谢谢你能告诉我的一切。
<script src="lightgl.js"></script>
<script src='vendor/three.js/build/three.min.js'></script>
<script src='vendor/three.js/build/stats.min.js'></script>
<script src="vendor/csg.js"></script>
<script src="vendor/ThreeCSG.js"></script>
</head>
<body bgcolor="black">
<script>
renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight,
1, 500);
camera.position.set(0, 0, 10);
camera.lookAt(new THREE.Vector3(0, 0, 0));
scene = new THREE.Scene();
////////////////// This is the CSG code/////////////////////
var CSGsphere =CSG.sphere({radius: 1.3 });
CSGsphere.setColor(1, 0, 0);
var CSGcube= CSG.cube({center: [1,1,1]});
CSGcube.setColor(0,1, 0);
var combined = CSGsphere.subtract(CSGcube);
var resultGeo= THREE.CSG.fromCSG( combined );
var meshobject = new THREE.Mesh( resultGEO,new THREE.MeshNormalMaterial());
scene.add(meshobject);
renderer.render(scene, camera);
</script>发布于 2015-06-08 20:17:03
您运行的是过时版本的ThreeCSG,语法已更改,不再运行THREE.CSG.fromCSG()。
我从旧的源代码中复制了所需的内容,清除了所有错误,使它们可以与three.js r71一起运行,但返回的几何图形不是合法的THREE.geometry。
我会添加这条评论,但我没有足够的声誉。
https://stackoverflow.com/questions/24552546
复制相似问题