2014-03-02 72 views

回答

1

,你可以對每一個對象訪問

obj.constructor.name 

獲得「光」,「網格」和「網格」,但前提是你的three.js沒有被縮小。

1

editor我使用此代碼到:

var getObjectType = function (object) { 

    var types = { 

     'Scene': THREE.Scene, 
     'PerspectiveCamera': THREE.PerspectiveCamera, 
     'AmbientLight': THREE.AmbientLight, 
     'DirectionalLight': THREE.DirectionalLight, 
     'HemisphereLight': THREE.HemisphereLight, 
     'PointLight': THREE.PointLight, 
     'SpotLight': THREE.SpotLight, 
     'Mesh': THREE.Mesh, 
     'Sprite': THREE.Sprite, 
     'Object3D': THREE.Object3D 

    }; 

    for (var type in types) { 

     if (object instanceof types[ type ]) return type; 

    } 

}; 
相關問題