//那么,我如何找到以下
的解决方法 s.getDescendants()=[THREE.Light,THREE.Mesh,THREE.Mesh]
//我想要什么[THREE.LIGHT,THREE.Mesh,THREE.Mesh] //我得到了什么[object Object,object Object,object Object]
答案 0 :(得分:1)
你可以访问
obj.constructor.name
在每个单独的Object上获取“Light”,“Mesh”和“Mesh”,但前提是你的three.js没有缩小。
答案 1 :(得分: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;
}
};