ソースを参照

Added type property to all relevant objects.

Mr.doob 11 年 前
コミット
2efc87a00d
59 ファイル変更153 行追加109 行削除
  1. 0 91
      editor/js/Editor.js
  2. 1 1
      editor/js/Sidebar.Geometry.js
  3. 1 1
      editor/js/Sidebar.Material.js
  4. 1 1
      editor/js/Sidebar.Object3D.js
  5. 4 9
      editor/js/Sidebar.Scene.js
  6. 2 0
      src/cameras/Camera.js
  7. 2 0
      src/cameras/CubeCamera.js
  8. 2 0
      src/cameras/OrthographicCamera.js
  9. 2 0
      src/cameras/PerspectiveCamera.js
  10. 1 0
      src/core/BufferGeometry.js
  11. 1 0
      src/core/Geometry.js
  12. 1 0
      src/core/Object3D.js
  13. 2 0
      src/extras/geometries/BoxGeometry.js
  14. 2 0
      src/extras/geometries/CircleGeometry.js
  15. 2 0
      src/extras/geometries/CylinderGeometry.js
  16. 2 0
      src/extras/geometries/ExtrudeGeometry.js
  17. 6 5
      src/extras/geometries/IcosahedronGeometry.js
  18. 10 0
      src/extras/geometries/LatheGeometry.js
  19. 7 0
      src/extras/geometries/OctahedronGeometry.js
  20. 8 0
      src/extras/geometries/ParametricGeometry.js
  21. 2 0
      src/extras/geometries/PlaneGeometry.js
  22. 9 0
      src/extras/geometries/PolyhedronGeometry.js
  23. 11 0
      src/extras/geometries/RingGeometry.js
  24. 2 0
      src/extras/geometries/ShapeGeometry.js
  25. 2 0
      src/extras/geometries/SphereGeometry.js
  26. 7 0
      src/extras/geometries/TetrahedronGeometry.js
  27. 2 0
      src/extras/geometries/TextGeometry.js
  28. 2 0
      src/extras/geometries/TorusGeometry.js
  29. 2 0
      src/extras/geometries/TorusKnotGeometry.js
  30. 2 0
      src/extras/geometries/TubeGeometry.js
  31. 2 0
      src/lights/AmbientLight.js
  32. 2 0
      src/lights/AreaLight.js
  33. 2 0
      src/lights/DirectionalLight.js
  34. 2 0
      src/lights/HemisphereLight.js
  35. 2 0
      src/lights/Light.js
  36. 2 0
      src/lights/PointLight.js
  37. 2 0
      src/lights/SpotLight.js
  38. 2 0
      src/materials/LineBasicMaterial.js
  39. 2 0
      src/materials/LineDashedMaterial.js
  40. 1 0
      src/materials/Material.js
  41. 2 0
      src/materials/MeshBasicMaterial.js
  42. 2 0
      src/materials/MeshDepthMaterial.js
  43. 1 0
      src/materials/MeshFaceMaterial.js
  44. 2 0
      src/materials/MeshLambertMaterial.js
  45. 2 0
      src/materials/MeshNormalMaterial.js
  46. 2 0
      src/materials/MeshPhongMaterial.js
  47. 2 0
      src/materials/PointCloudMaterial.js
  48. 2 0
      src/materials/RawShaderMaterial.js
  49. 2 0
      src/materials/ShaderMaterial.js
  50. 2 0
      src/materials/SpriteCanvasMaterial.js
  51. 1 1
      src/materials/SpriteMaterial.js
  52. 2 0
      src/objects/Group.js
  53. 2 0
      src/objects/Line.js
  54. 2 0
      src/objects/Mesh.js
  55. 2 0
      src/objects/MorphAnimMesh.js
  56. 2 0
      src/objects/PointCloud.js
  57. 2 0
      src/objects/SkinnedMesh.js
  58. 2 0
      src/objects/Sprite.js
  59. 2 0
      src/scenes/Scene.js

+ 0 - 91
editor/js/Editor.js

@@ -325,97 +325,6 @@ Editor.prototype = {
 
 		this.select( null );
 
-	},
-
-	// utils
-
-	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,
-			'SkinnedMesh': THREE.SkinnedMesh,
-			'Mesh': THREE.Mesh,
-			'Sprite': THREE.Sprite,
-			'Group': THREE.Group,
-			'Object3D': THREE.Object3D
-
-		};
-
-		for ( var type in types ) {
-
-			if ( object instanceof types[ type ] ) return type;
-
-		}
-
-	},
-
-	getGeometryType: function ( geometry ) {
-
-		var types = {
-
-			'BoxGeometry': THREE.BoxGeometry,
-			'CircleGeometry': THREE.CircleGeometry,
-			'CylinderGeometry': THREE.CylinderGeometry,
-			'ExtrudeGeometry': THREE.ExtrudeGeometry,
-			'IcosahedronGeometry': THREE.IcosahedronGeometry,
-			'LatheGeometry': THREE.LatheGeometry,
-			'OctahedronGeometry': THREE.OctahedronGeometry,
-			'ParametricGeometry': THREE.ParametricGeometry,
-			'PlaneGeometry': THREE.PlaneGeometry,
-			'PolyhedronGeometry': THREE.PolyhedronGeometry,
-			'ShapeGeometry': THREE.ShapeGeometry,
-			'SphereGeometry': THREE.SphereGeometry,
-			'TetrahedronGeometry': THREE.TetrahedronGeometry,
-			'TextGeometry': THREE.TextGeometry,
-			'TorusGeometry': THREE.TorusGeometry,
-			'TorusKnotGeometry': THREE.TorusKnotGeometry,
-			'TubeGeometry': THREE.TubeGeometry,
-			'Geometry': THREE.Geometry,
-			'BufferGeometry': THREE.BufferGeometry
-
-		};
-
-		for ( var type in types ) {
-
-			if ( geometry instanceof types[ type ] ) return type;
-
-		}
-
-	},
-
-	getMaterialType: function ( material ) {
-
-		var types = {
-
-			'LineBasicMaterial': THREE.LineBasicMaterial,
-			'LineDashedMaterial': THREE.LineDashedMaterial,
-			'MeshBasicMaterial': THREE.MeshBasicMaterial,
-			'MeshDepthMaterial': THREE.MeshDepthMaterial,
-			'MeshFaceMaterial': THREE.MeshFaceMaterial,
-			'MeshLambertMaterial': THREE.MeshLambertMaterial,
-			'MeshNormalMaterial': THREE.MeshNormalMaterial,
-			'MeshPhongMaterial': THREE.MeshPhongMaterial,
-			'PointCloudMaterial': THREE.PointCloudMaterial,
-			'ShaderMaterial': THREE.ShaderMaterial,
-			'SpriteCanvasMaterial': THREE.SpriteCanvasMaterial,
-			'SpriteMaterial': THREE.SpriteMaterial,
-			'Material': THREE.Material
-
-		};
-
-		for ( var type in types ) {
-
-			if ( material instanceof types[ type ] ) return type;
-
-		}
-
 	}
 
 }

+ 1 - 1
editor/js/Sidebar.Geometry.js

@@ -67,7 +67,7 @@ Sidebar.Geometry = function ( editor ) {
 
 			container.setDisplay( 'block' );
 
-			geometryType.setValue( editor.getGeometryType( object.geometry ) );
+			geometryType.setValue( geometry.type );
 
 			geometryUUID.setValue( geometry.uuid );
 			geometryName.setValue( geometry.name );

+ 1 - 1
editor/js/Sidebar.Material.js

@@ -701,7 +701,7 @@ Sidebar.Material = function ( editor ) {
 
 			}
 
-			materialClass.setValue( editor.getMaterialType( material ) );
+			materialClass.setValue( material.type );
 
 			if ( material.color !== undefined ) {
 

+ 1 - 1
editor/js/Sidebar.Object3D.js

@@ -456,7 +456,7 @@ Sidebar.Object3D = function ( editor ) {
 
 	function updateUI( object ) {
 
-		objectType.setValue( editor.getObjectType( object ) );
+		objectType.setValue( object.type );
 
 		objectUUID.setValue( object.uuid );
 		objectName.setValue( object.name );

+ 4 - 9
editor/js/Sidebar.Scene.js

@@ -114,31 +114,26 @@ Sidebar.Scene = function ( editor ) {
 	var refreshUI = function () {
 
 		var scene = editor.scene;
-		var sceneType = editor.getObjectType( scene );
 
 		var options = [];
 
-		options.push( { value: scene.id, html: '<span class="type ' + sceneType + '"></span> ' + scene.name } );
+		options.push( { value: scene.id, html: '<span class="type ' + scene.type + '"></span> ' + scene.name } );
 
 		( function addObjects( objects, pad ) {
 
 			for ( var i = 0, l = objects.length; i < l; i ++ ) {
 
 				var object = objects[ i ];
-				var objectType = editor.getObjectType( object );
 
-				var html = pad + '<span class="type ' + objectType + '"></span> ' + object.name;
+				var html = pad + '<span class="type ' + object.type + '"></span> ' + object.name;
 
 				if ( object instanceof THREE.Mesh ) {
 
 					var geometry = object.geometry;
 					var material = object.material;
 
-					var geometryType = editor.getGeometryType( geometry );
-					var materialType = editor.getMaterialType( material );
-
-					html += ' <span class="type ' + geometryType + '"></span> ' + geometry.name;
-					html += ' <span class="type ' + materialType + '"></span> ' + material.name;
+					html += ' <span class="type ' + geometry.type + '"></span> ' + geometry.name;
+					html += ' <span class="type ' + material.type + '"></span> ' + material.name;
 
 				}
 

+ 2 - 0
src/cameras/Camera.js

@@ -8,6 +8,8 @@ THREE.Camera = function () {
 
 	THREE.Object3D.call( this );
 
+	this.type = 'Camera';
+
 	this.matrixWorldInverse = new THREE.Matrix4();
 	this.projectionMatrix = new THREE.Matrix4();
 

+ 2 - 0
src/cameras/CubeCamera.js

@@ -9,6 +9,8 @@ THREE.CubeCamera = function ( near, far, cubeResolution ) {
 
 	THREE.Object3D.call( this );
 
+	this.type = 'CubeCamera';
+
 	var fov = 90, aspect = 1;
 
 	var cameraPX = new THREE.PerspectiveCamera( fov, aspect, near, far );

+ 2 - 0
src/cameras/OrthographicCamera.js

@@ -6,6 +6,8 @@ THREE.OrthographicCamera = function ( left, right, top, bottom, near, far ) {
 
 	THREE.Camera.call( this );
 
+	this.type = 'OrthographicCamera';
+
 	this.left = left;
 	this.right = right;
 	this.top = top;

+ 2 - 0
src/cameras/PerspectiveCamera.js

@@ -8,6 +8,8 @@ THREE.PerspectiveCamera = function ( fov, aspect, near, far ) {
 
 	THREE.Camera.call( this );
 
+	this.type = 'PerspectiveCamera';
+
 	this.fov = fov !== undefined ? fov : 50;
 	this.aspect = aspect !== undefined ? aspect : 1;
 	this.near = near !== undefined ? near : 0.1;

+ 1 - 0
src/core/BufferGeometry.js

@@ -8,6 +8,7 @@ THREE.BufferGeometry = function () {
 	this.uuid = THREE.Math.generateUUID();
 
 	this.name = '';
+	this.type = 'BufferGeometry';
 
 	this.attributes = {};
 	this.drawcalls = [];

+ 1 - 0
src/core/Geometry.js

@@ -13,6 +13,7 @@ THREE.Geometry = function () {
 	this.uuid = THREE.Math.generateUUID();
 
 	this.name = '';
+	this.type = 'Geometry';
 
 	this.vertices = [];
 	this.colors = [];  // one-to-one vertex colors, used in Points and Line

+ 1 - 0
src/core/Object3D.js

@@ -11,6 +11,7 @@ THREE.Object3D = function () {
 	this.uuid = THREE.Math.generateUUID();
 
 	this.name = '';
+	this.type = 'Object3D';
 
 	this.parent = undefined;
 	this.children = [];

+ 2 - 0
src/extras/geometries/BoxGeometry.js

@@ -7,6 +7,8 @@ THREE.BoxGeometry = function ( width, height, depth, widthSegments, heightSegmen
 
 	THREE.Geometry.call( this );
 
+	this.type = 'BoxGeometry';
+
 	this.parameters = {
 		width: width,
 		height: height,

+ 2 - 0
src/extras/geometries/CircleGeometry.js

@@ -6,6 +6,8 @@ THREE.CircleGeometry = function ( radius, segments, thetaStart, thetaLength ) {
 
 	THREE.Geometry.call( this );
 
+	this.type = 'CircleGeometry';
+
 	this.parameters = {
 		radius: radius,
 		segments: segments,

+ 2 - 0
src/extras/geometries/CylinderGeometry.js

@@ -6,6 +6,8 @@ THREE.CylinderGeometry = function ( radiusTop, radiusBottom, height, radialSegme
 
 	THREE.Geometry.call( this );
 
+	this.type = 'CylinderGeometry';
+
 	this.parameters = {
 		radiusTop: radiusTop,
 		radiusBottom: radiusBottom,

+ 2 - 0
src/extras/geometries/ExtrudeGeometry.js

@@ -33,6 +33,8 @@ THREE.ExtrudeGeometry = function ( shapes, options ) {
 
 	THREE.Geometry.call( this );
 
+	this.type = 'ExtrudeGeometry';
+
 	shapes = shapes instanceof Array ? shapes : [ shapes ];
 
 	this.addShapeList( shapes, options );

+ 6 - 5
src/extras/geometries/IcosahedronGeometry.js

@@ -4,11 +4,6 @@
 
 THREE.IcosahedronGeometry = function ( radius, detail ) {
 
-	this.parameters = {
-		radius: radius,
-		detail: detail
-	};
-
 	var t = ( 1 + Math.sqrt( 5 ) ) / 2;
 
 	var vertices = [
@@ -26,6 +21,12 @@ THREE.IcosahedronGeometry = function ( radius, detail ) {
 
 	THREE.PolyhedronGeometry.call( this, vertices, indices, radius, detail );
 
+	this.type = 'IcosahedronGeometry';
+
+	this.parameters = {
+		radius: radius,
+		detail: detail
+	};
 };
 
 THREE.IcosahedronGeometry.prototype = Object.create( THREE.Geometry.prototype );

+ 10 - 0
src/extras/geometries/LatheGeometry.js

@@ -10,10 +10,20 @@
 // phiStart - the starting radian
 // phiLength - the radian (0 to 2*PI) range of the lathed section
 //    2*pi is a closed lathe, less than 2PI is a portion.
+
 THREE.LatheGeometry = function ( points, segments, phiStart, phiLength ) {
 
 	THREE.Geometry.call( this );
 
+	this.type = 'LatheGeometry';
+
+	this.parameters = {
+		points: points,
+		segments: segments,
+		phiStart: phiStart,
+		phiLength: phiLength
+	};
+
 	segments = segments || 12;
 	phiStart = phiStart || 0;
 	phiLength = phiLength || 2 * Math.PI;

+ 7 - 0
src/extras/geometries/OctahedronGeometry.js

@@ -18,6 +18,13 @@ THREE.OctahedronGeometry = function ( radius, detail ) {
 	];
 
 	THREE.PolyhedronGeometry.call( this, vertices, indices, radius, detail );
+
+	this.type = 'OctahedronGeometry';
+
+	this.parameters = {
+		radius: radius,
+		detail: detail
+	};
 };
 
 THREE.OctahedronGeometry.prototype = Object.create( THREE.Geometry.prototype );

+ 8 - 0
src/extras/geometries/ParametricGeometry.js

@@ -11,6 +11,14 @@ THREE.ParametricGeometry = function ( func, slices, stacks ) {
 
 	THREE.Geometry.call( this );
 
+	this.type = 'ParametricGeometry';
+
+	this.parameters = {
+		func: func,
+		slices: slices,
+		stacks: stacks
+	};
+
 	var verts = this.vertices;
 	var faces = this.faces;
 	var uvs = this.faceVertexUvs[ 0 ];

+ 2 - 0
src/extras/geometries/PlaneGeometry.js

@@ -7,6 +7,8 @@ THREE.PlaneGeometry = function ( width, height, widthSegments, heightSegments )
 
 	THREE.Geometry.call( this );
 
+	this.type = 'PlaneGeometry';
+	
 	this.parameters = {
 		width: width,
 		height: height,

+ 9 - 0
src/extras/geometries/PolyhedronGeometry.js

@@ -8,6 +8,15 @@ THREE.PolyhedronGeometry = function ( vertices, indices, radius, detail ) {
 
 	THREE.Geometry.call( this );
 
+	this.type = 'PolyhedronGeometry';
+
+	this.parameters = {
+		vertices: vertices,
+		indices: indices,
+		radius: radius,
+		detail: detail
+	};
+
 	radius = radius || 1;
 	detail = detail || 0;
 

+ 11 - 0
src/extras/geometries/RingGeometry.js

@@ -6,6 +6,17 @@ THREE.RingGeometry = function ( innerRadius, outerRadius, thetaSegments, phiSegm
 
 	THREE.Geometry.call( this );
 
+	this.type = 'RingGeometry';
+
+	this.parameters = {
+		innerRadius: innerRadius,
+		outerRadius: outerRadius,
+		thetaSegments: thetaSegments,
+		phiSegments: phiSegments,
+		thetaStart: thetaStart,
+		thetaLength: thetaLength
+	};
+
 	innerRadius = innerRadius || 0;
 	outerRadius = outerRadius || 50;
 

+ 2 - 0
src/extras/geometries/ShapeGeometry.js

@@ -18,6 +18,8 @@ THREE.ShapeGeometry = function ( shapes, options ) {
 
 	THREE.Geometry.call( this );
 
+	this.type = 'ShapeGeometry';
+
 	if ( shapes instanceof Array === false ) shapes = [ shapes ];
 
 	this.addShapeList( shapes, options );

+ 2 - 0
src/extras/geometries/SphereGeometry.js

@@ -6,6 +6,8 @@ THREE.SphereGeometry = function ( radius, widthSegments, heightSegments, phiStar
 
 	THREE.Geometry.call( this );
 
+	this.type = 'SphereGeometry';
+
 	this.parameters = {
 		radius: radius,
 		widthSegments: widthSegments,

+ 7 - 0
src/extras/geometries/TetrahedronGeometry.js

@@ -14,6 +14,13 @@ THREE.TetrahedronGeometry = function ( radius, detail ) {
 
 	THREE.PolyhedronGeometry.call( this, vertices, indices, radius, detail );
 
+	this.type = 'TetrahedronGeometry';
+
+	this.parameters = {
+		radius: radius,
+		detail: detail
+	};
+
 };
 
 THREE.TetrahedronGeometry.prototype = Object.create( THREE.Geometry.prototype );

+ 2 - 0
src/extras/geometries/TextGeometry.js

@@ -54,6 +54,8 @@ THREE.TextGeometry = function ( text, parameters ) {
 
 	THREE.ExtrudeGeometry.call( this, textShapes, parameters );
 
+	this.type = 'TextGeometry';
+
 };
 
 THREE.TextGeometry.prototype = Object.create( THREE.ExtrudeGeometry.prototype );

+ 2 - 0
src/extras/geometries/TorusGeometry.js

@@ -8,6 +8,8 @@ THREE.TorusGeometry = function ( radius, tube, radialSegments, tubularSegments,
 
 	THREE.Geometry.call( this );
 
+	this.type = 'TorusGeometry';
+
 	this.parameters = {
 		radius: radius,
 		tube: tube,

+ 2 - 0
src/extras/geometries/TorusKnotGeometry.js

@@ -7,6 +7,8 @@ THREE.TorusKnotGeometry = function ( radius, tube, radialSegments, tubularSegmen
 
 	THREE.Geometry.call( this );
 
+	this.type = 'TorusKnotGeometry';
+
 	this.parameters = {
 		radius: radius,
 		tube: tube,

+ 2 - 0
src/extras/geometries/TubeGeometry.js

@@ -15,6 +15,8 @@ THREE.TubeGeometry = function ( path, segments, radius, radialSegments, closed )
 
 	THREE.Geometry.call( this );
 
+	this.type = 'TubeGeometry';
+
 	this.parameters = {
 		path: path,
 		segments: segments,

+ 2 - 0
src/lights/AmbientLight.js

@@ -6,6 +6,8 @@ THREE.AmbientLight = function ( color ) {
 
 	THREE.Light.call( this, color );
 
+	this.type = 'AmbientLight';
+
 };
 
 THREE.AmbientLight.prototype = Object.create( THREE.Light.prototype );

+ 2 - 0
src/lights/AreaLight.js

@@ -7,6 +7,8 @@ THREE.AreaLight = function ( color, intensity ) {
 
 	THREE.Light.call( this, color );
 
+	this.type = 'AreaLight';
+
 	this.normal = new THREE.Vector3( 0, - 1, 0 );
 	this.right = new THREE.Vector3( 1, 0, 0 );
 

+ 2 - 0
src/lights/DirectionalLight.js

@@ -7,6 +7,8 @@ THREE.DirectionalLight = function ( color, intensity ) {
 
 	THREE.Light.call( this, color );
 
+	this.type = 'DirectionalLight';
+
 	this.position.set( 0, 1, 0 );
 	this.target = new THREE.Object3D();
 

+ 2 - 0
src/lights/HemisphereLight.js

@@ -6,6 +6,8 @@ THREE.HemisphereLight = function ( skyColor, groundColor, intensity ) {
 
 	THREE.Light.call( this, skyColor );
 
+	this.type = 'HemisphereLight';
+
 	this.position.set( 0, 100, 0 );
 
 	this.groundColor = new THREE.Color( groundColor );

+ 2 - 0
src/lights/Light.js

@@ -7,6 +7,8 @@ THREE.Light = function ( color ) {
 
 	THREE.Object3D.call( this );
 
+	this.type = 'Light';
+	
 	this.color = new THREE.Color( color );
 
 };

+ 2 - 0
src/lights/PointLight.js

@@ -6,6 +6,8 @@ THREE.PointLight = function ( color, intensity, distance ) {
 
 	THREE.Light.call( this, color );
 
+	this.type = 'PointLight';
+
 	this.intensity = ( intensity !== undefined ) ? intensity : 1;
 	this.distance = ( distance !== undefined ) ? distance : 0;
 

+ 2 - 0
src/lights/SpotLight.js

@@ -6,6 +6,8 @@ THREE.SpotLight = function ( color, intensity, distance, angle, exponent ) {
 
 	THREE.Light.call( this, color );
 
+	this.type = 'SpotLight';
+
 	this.position.set( 0, 1, 0 );
 	this.target = new THREE.Object3D();
 

+ 2 - 0
src/materials/LineBasicMaterial.js

@@ -24,6 +24,8 @@ THREE.LineBasicMaterial = function ( parameters ) {
 
 	THREE.Material.call( this );
 
+	this.type = 'LineBasicMaterial';
+
 	this.color = new THREE.Color( 0xffffff );
 
 	this.linewidth = 1;

+ 2 - 0
src/materials/LineDashedMaterial.js

@@ -25,6 +25,8 @@ THREE.LineDashedMaterial = function ( parameters ) {
 
 	THREE.Material.call( this );
 
+	this.type = 'LineDashedMaterial';
+
 	this.color = new THREE.Color( 0xffffff );
 
 	this.linewidth = 1;

+ 1 - 0
src/materials/Material.js

@@ -9,6 +9,7 @@ THREE.Material = function () {
 	this.uuid = THREE.Math.generateUUID();
 
 	this.name = '';
+	this.type = 'Material';
 
 	this.side = THREE.FrontSide;
 

+ 2 - 0
src/materials/MeshBasicMaterial.js

@@ -39,6 +39,8 @@ THREE.MeshBasicMaterial = function ( parameters ) {
 
 	THREE.Material.call( this );
 
+	this.type = 'MeshBasicMaterial';
+
 	this.color = new THREE.Color( 0xffffff ); // emissive
 
 	this.map = null;

+ 2 - 0
src/materials/MeshDepthMaterial.js

@@ -18,6 +18,8 @@ THREE.MeshDepthMaterial = function ( parameters ) {
 
 	THREE.Material.call( this );
 
+	this.type = 'MeshDepthMaterial';
+
 	this.morphTargets = false;
 	this.wireframe = false;
 	this.wireframeLinewidth = 1;

+ 1 - 0
src/materials/MeshFaceMaterial.js

@@ -4,6 +4,7 @@
 
 THREE.MeshFaceMaterial = function ( materials ) {
 
+	this.type = 'MeshFaceMaterial';
 	this.materials = materials instanceof Array ? materials : [];
 
 };

+ 2 - 0
src/materials/MeshLambertMaterial.js

@@ -43,6 +43,8 @@ THREE.MeshLambertMaterial = function ( parameters ) {
 
 	THREE.Material.call( this );
 
+	this.type = 'MeshLambertMaterial';
+
 	this.color = new THREE.Color( 0xffffff ); // diffuse
 	this.ambient = new THREE.Color( 0xffffff );
 	this.emissive = new THREE.Color( 0x000000 );

+ 2 - 0
src/materials/MeshNormalMaterial.js

@@ -18,6 +18,8 @@ THREE.MeshNormalMaterial = function ( parameters ) {
 
 	THREE.Material.call( this, parameters );
 
+	this.type = 'MeshNormalMaterial';
+
 	this.shading = THREE.FlatShading;
 
 	this.wireframe = false;

+ 2 - 0
src/materials/MeshPhongMaterial.js

@@ -51,6 +51,8 @@ THREE.MeshPhongMaterial = function ( parameters ) {
 
 	THREE.Material.call( this );
 
+	this.type = 'MeshPhongMaterial';
+
 	this.color = new THREE.Color( 0xffffff ); // diffuse
 	this.ambient = new THREE.Color( 0xffffff );
 	this.emissive = new THREE.Color( 0x000000 );

+ 2 - 0
src/materials/PointCloudMaterial.js

@@ -23,6 +23,8 @@ THREE.PointCloudMaterial = function ( parameters ) {
 
 	THREE.Material.call( this );
 
+	this.type = 'PointCloudMaterial';
+
 	this.color = new THREE.Color( 0xffffff );
 
 	this.map = null;

+ 2 - 0
src/materials/RawShaderMaterial.js

@@ -6,6 +6,8 @@ THREE.RawShaderMaterial = function ( parameters ) {
 
 	THREE.ShaderMaterial.call( this, parameters );
 
+	this.type = 'RawShaderMaterial';
+
 };
 
 THREE.RawShaderMaterial.prototype = Object.create( THREE.ShaderMaterial.prototype );

+ 2 - 0
src/materials/ShaderMaterial.js

@@ -32,6 +32,8 @@ THREE.ShaderMaterial = function ( parameters ) {
 
 	THREE.Material.call( this );
 
+	this.type = 'ShaderMaterial';
+
 	this.defines = {};
 	this.uniforms = {};
 	this.attributes = null;

+ 2 - 0
src/materials/SpriteCanvasMaterial.js

@@ -13,6 +13,8 @@ THREE.SpriteCanvasMaterial = function ( parameters ) {
 
 	THREE.Material.call( this );
 
+	this.type = 'SpriteCanvasMaterial';
+
 	this.color = new THREE.Color( 0xffffff );
 	this.program = function ( context, color ) {};
 

+ 1 - 1
src/materials/SpriteMaterial.js

@@ -21,7 +21,7 @@ THREE.SpriteMaterial = function ( parameters ) {
 
 	THREE.Material.call( this );
 
-	// defaults
+	this.type = 'SpriteMaterial';
 
 	this.color = new THREE.Color( 0xffffff );
 	this.map = null;

+ 2 - 0
src/objects/Group.js

@@ -6,6 +6,8 @@ THREE.Group = function () {
 
 	THREE.Object3D.call( this );
 
+	this.type = 'Group';
+
 };
 
 THREE.Group.prototype = Object.create( THREE.Object3D.prototype );

+ 2 - 0
src/objects/Line.js

@@ -6,6 +6,8 @@ THREE.Line = function ( geometry, material, type ) {
 
 	THREE.Object3D.call( this );
 
+	this.type = 'Line';
+
 	this.geometry = geometry !== undefined ? geometry : new THREE.Geometry();
 	this.material = material !== undefined ? material : new THREE.LineBasicMaterial( { color: Math.random() * 0xffffff } );
 

+ 2 - 0
src/objects/Mesh.js

@@ -9,6 +9,8 @@ THREE.Mesh = function ( geometry, material ) {
 
 	THREE.Object3D.call( this );
 
+	this.type = 'Mesh';
+	
 	this.geometry = geometry !== undefined ? geometry : new THREE.Geometry();
 	this.material = material !== undefined ? material : new THREE.MeshBasicMaterial( { color: Math.random() * 0xffffff } );
 

+ 2 - 0
src/objects/MorphAnimMesh.js

@@ -6,6 +6,8 @@ THREE.MorphAnimMesh = function ( geometry, material ) {
 
 	THREE.Mesh.call( this, geometry, material );
 
+	this.type = 'MorphAnimMesh';
+
 	// API
 
 	this.duration = 1000; // milliseconds

+ 2 - 0
src/objects/PointCloud.js

@@ -6,6 +6,8 @@ THREE.PointCloud = function ( geometry, material ) {
 
 	THREE.Object3D.call( this );
 
+	this.type = 'PointCloud';
+
 	this.geometry = geometry !== undefined ? geometry : new THREE.Geometry();
 	this.material = material !== undefined ? material : new THREE.PointCloudMaterial( { color: Math.random() * 0xffffff } );
 

+ 2 - 0
src/objects/SkinnedMesh.js

@@ -8,6 +8,8 @@ THREE.SkinnedMesh = function ( geometry, material, useVertexTexture ) {
 
 	THREE.Mesh.call( this, geometry, material );
 
+	this.type = 'SkinnedMesh';
+
 	this.bindMode = "attached";
 	this.bindMatrix = new THREE.Matrix4();
 	this.bindMatrixInverse = new THREE.Matrix4();

+ 2 - 0
src/objects/Sprite.js

@@ -18,6 +18,8 @@ THREE.Sprite = ( function () {
 
 		THREE.Object3D.call( this );
 
+		this.type = 'Sprite';
+
 		this.geometry = geometry;
 		this.material = ( material !== undefined ) ? material : new THREE.SpriteMaterial();
 

+ 2 - 0
src/scenes/Scene.js

@@ -6,6 +6,8 @@ THREE.Scene = function () {
 
 	THREE.Object3D.call( this );
 
+	this.type = 'Scene';
+
 	this.fog = null;
 	this.overrideMaterial = null;