2013-10-16 81 views
0

刪除對象我加入這樣一個對象:無法從現場

root = new THREE.Object3D(); 
scene.add(root); 

var geometry = new THREE.PlaneGeometry(300, 150, 1, 1); 
var material = new THREE.MeshBasicMaterial({color: 0x676767, wireframe: false, side: THREE.DoubleSide}); 
rect = new THREE.Mesh(geometry, material); 
rect.rotation.x = Math.PI/2; 
rect.name = "rect"; 
root.add(rect); 

再後來我嘗試刪除「矩形」這一點:

function removeEntity(object){ 
    root.remove(object.name); 
} 

不管我怎麼努力我無法刪除此對象。 任何想法?

+1

'root.remove(object)'Not object.name。您可以通過名稱'.getObjectByName(name,recursive)'獲得對象,然後將其刪除。 – uhura

回答

0

hmm?

function removeEntity(name){ 
    root.remove(name); 
}