這裏我碰到了這個問題,因爲我需要將兩個幾何體(或網格)合併爲一個。使用three.js的早期版本有一個很好的功能:如何使用three.js r71合併兩個幾何體或網格物體?
THREE.GeometryUtils.merge(pendulum, ball);
但是,它不在新版本了。
我試圖合併pendulum
和ball
用下面的代碼:
ball
是網狀。
var ballGeo = new THREE.SphereGeometry(24,35,35);
var ballMat = new THREE.MeshPhongMaterial({color: 0xF7FE2E});
var ball = new THREE.Mesh(ballGeo, ballMat);
ball.position.set(0,0,0);
var pendulum = new THREE.CylinderGeometry(1, 1, 20, 16);
ball.updateMatrix();
pendulum.merge(ball.geometry, ball.matrix);
scene.add(pendulum);
畢竟,我得到了以下錯誤:
THREE.Object3D.add: object not an instance of THREE.Object3D. THREE.CylinderGeometry {uuid: "688B0EB1-70F7-4C51-86DB-5B1B90A8A24C", name: "", type: "CylinderGeometry", vertices: Array[1332], colors: Array[0]…}THREE.error @ three_r71.js:35THREE.Object3D.add @ three_r71.js:7770(anonymous function) @ pendulum.js:20
_「不用爲沒有泰勒康普頓的事蹟在生活中」 _ - _Lady Galadriel_ 感謝這個 – LaughingMan