第一段是原本畫(huà)網(wǎng)格的代碼 第二段我使用geometry.merge()方法的代碼 不知道哪里寫(xiě)錯(cuò)了 不報(bào)錯(cuò) 也出不來(lái) 請(qǐng)前輩指教function initObject() { //1.在x軸上定義兩個(gè)點(diǎn)p1 p2 var geometry = new THREE.Geometry(); geometry.vertices.push(new THREE.Vector3(-500, 0, 0)); geometry.vertices.push(new THREE.Vector3(500, 0, 0)); //2.主要在于這里的算法,從右、下角開(kāi)始畫(huà) for (var i = 0; i <= 20; i++) { //畫(huà)橫線 var line = new THREE.Line(geometry, new THREE.LineBasicMaterial({ color: 0x000000, opacity: 0.2 })); line.position.z = (i * 50) - 500; scene.add(line); var line = new THREE.Line(geometry, new THREE.LineBasicMaterial({ color: 0x000000, opacity: 0.2 })); line.position.x = (i * 50) - 500; line.rotation.y = 90 * Math.PI / 180; //轉(zhuǎn)90度 scene.add(line); } }
three.js 使用geometry.merge() 優(yōu)化
尚方寶劍之說(shuō)
2019-03-06 17:15:58