Kaynağa Gözat

Added THREE.Group.

Mr.doob 11 yıl önce
ebeveyn
işleme
aaaabab47f

+ 14 - 0
build/three.js

@@ -14280,6 +14280,20 @@ THREE.DataTexture.prototype.clone = function () {
 
 };
 
+// File:src/objects/Group.js
+
+/**
+ * @author mrdoob / http://mrdoob.com/
+ */
+
+THREE.Group = function () {
+
+	THREE.Object3D.call( this );
+
+};
+
+THREE.Group.prototype = Object.create( THREE.Object3D.prototype );
+
 // File:src/objects/PointCloud.js
 
 /**

+ 2 - 2
build/three.min.js

@@ -317,8 +317,8 @@ g?g:THREE.RGBAFormat;this.type=void 0!==h?h:THREE.UnsignedByteType;this.offset=n
 THREE.Texture.prototype={constructor:THREE.Texture,get needsUpdate(){return this._needsUpdate},set needsUpdate(a){!0===a&&this.update();this._needsUpdate=a},clone:function(a){void 0===a&&(a=new THREE.Texture);a.image=this.image;a.mipmaps=this.mipmaps.slice(0);a.mapping=this.mapping;a.wrapS=this.wrapS;a.wrapT=this.wrapT;a.magFilter=this.magFilter;a.minFilter=this.minFilter;a.anisotropy=this.anisotropy;a.format=this.format;a.type=this.type;a.offset.copy(this.offset);a.repeat.copy(this.repeat);a.generateMipmaps=
 this.generateMipmaps;a.premultiplyAlpha=this.premultiplyAlpha;a.flipY=this.flipY;a.unpackAlignment=this.unpackAlignment;return a},update:function(){this.dispatchEvent({type:"update"})},dispose:function(){this.dispatchEvent({type:"dispose"})}};THREE.EventDispatcher.prototype.apply(THREE.Texture.prototype);THREE.TextureIdCount=0;THREE.CubeTexture=function(a,b,c,d,e,f,g,h,k){THREE.Texture.call(this,a,b,c,d,e,f,g,h,k);this.images=a};THREE.CubeTexture.prototype=Object.create(THREE.Texture.prototype);
 THREE.CubeTexture.clone=function(a){void 0===a&&(a=new THREE.CubeTexture);THREE.Texture.prototype.clone.call(this,a);a.images=this.images;return a};THREE.CompressedTexture=function(a,b,c,d,e,f,g,h,k,m,n){THREE.Texture.call(this,null,f,g,h,k,m,d,e,n);this.image={width:b,height:c};this.mipmaps=a;this.generateMipmaps=!1};THREE.CompressedTexture.prototype=Object.create(THREE.Texture.prototype);
-THREE.CompressedTexture.prototype.clone=function(){var a=new THREE.CompressedTexture;THREE.Texture.prototype.clone.call(this,a);return a};THREE.DataTexture=function(a,b,c,d,e,f,g,h,k,m,n){THREE.Texture.call(this,null,f,g,h,k,m,d,e,n);this.image={data:a,width:b,height:c}};THREE.DataTexture.prototype=Object.create(THREE.Texture.prototype);THREE.DataTexture.prototype.clone=function(){var a=new THREE.DataTexture;THREE.Texture.prototype.clone.call(this,a);return a};
-THREE.PointCloud=function(a,b){THREE.Object3D.call(this);this.geometry=void 0!==a?a:new THREE.Geometry;this.material=void 0!==b?b:new THREE.PointCloudMaterial({color:16777215*Math.random()});this.sortParticles=!1};THREE.PointCloud.prototype=Object.create(THREE.Object3D.prototype);
+THREE.CompressedTexture.prototype.clone=function(){var a=new THREE.CompressedTexture;THREE.Texture.prototype.clone.call(this,a);return a};THREE.DataTexture=function(a,b,c,d,e,f,g,h,k,m,n){THREE.Texture.call(this,null,f,g,h,k,m,d,e,n);this.image={data:a,width:b,height:c}};THREE.DataTexture.prototype=Object.create(THREE.Texture.prototype);THREE.DataTexture.prototype.clone=function(){var a=new THREE.DataTexture;THREE.Texture.prototype.clone.call(this,a);return a};THREE.Group=function(){THREE.Object3D.call(this)};
+THREE.Group.prototype=Object.create(THREE.Object3D.prototype);THREE.PointCloud=function(a,b){THREE.Object3D.call(this);this.geometry=void 0!==a?a:new THREE.Geometry;this.material=void 0!==b?b:new THREE.PointCloudMaterial({color:16777215*Math.random()});this.sortParticles=!1};THREE.PointCloud.prototype=Object.create(THREE.Object3D.prototype);
 THREE.PointCloud.prototype.raycast=function(){var a=new THREE.Matrix4,b=new THREE.Ray;return function(c,d){var e=this,f=e.geometry,g=c.params.PointCloud.threshold;a.getInverse(this.matrixWorld);b.copy(c.ray).applyMatrix4(a);if(null===f.boundingBox||!1!==b.isIntersectionBox(f.boundingBox)){var h=g/((this.scale.x+this.scale.y+this.scale.z)/3),k=new THREE.Vector3,g=function(a,f){var g=b.distanceToPoint(a);if(g<h){var k=b.closestPointToPoint(a);k.applyMatrix4(e.matrixWorld);var m=c.ray.origin.distanceTo(k);
 d.push({distance:m,distanceToRay:g,point:k.clone(),index:f,face:null,object:e})}};if(f instanceof THREE.BufferGeometry){var m=f.attributes,n=m.position.array;if(void 0!==m.index){var m=m.index.array,p=f.offsets;0===p.length&&(p=[{start:0,count:m.length,index:0}]);for(var r=0,q=p.length;r<q;++r)for(var t=p[r].start,s=p[r].index,f=t,t=t+p[r].count;f<t;f++){var v=s+m[f];k.set(n[3*v],n[3*v+1],n[3*v+2]);g(k,v)}}else for(m=n.length/3,f=0;f<m;f++)k.set(n[3*f],n[3*f+1],n[3*f+2]),g(k,f)}else for(k=this.geometry.vertices,
 f=0;f<k.length;f++)g(k[f],f)}}}();THREE.PointCloud.prototype.clone=function(a){void 0===a&&(a=new THREE.PointCloud(this.geometry,this.material));a.sortParticles=this.sortParticles;THREE.Object3D.prototype.clone.call(this,a);return a};THREE.ParticleSystem=function(a,b){console.warn("THREE.ParticleSystem has been renamed to THREE.PointCloud.");return new THREE.PointCloud(a,b)};

+ 1 - 0
editor/js/Editor.js

@@ -329,6 +329,7 @@ Editor.prototype = {
 			'SkinnedMesh': THREE.SkinnedMesh,
 			'Mesh': THREE.Mesh,
 			'Sprite': THREE.Sprite,
+			'Group': THREE.Group,
 			'Object3D': THREE.Object3D
 
 		};

+ 4 - 4
editor/js/Menubar.Add.js

@@ -5,10 +5,10 @@ Menubar.Add = function ( editor ) {
 
 	// event handlers
 
-	function onObject3DOptionClick () {
+	function onGroupOptionClick () {
 
-		var mesh = new THREE.Object3D();
-		mesh.name = 'Object3D ' + ( ++ meshCount );
+		var mesh = new THREE.Group();
+		mesh.name = 'Group ' + ( ++ meshCount );
 
 		editor.addObject( mesh );
 		editor.select( mesh );
@@ -242,7 +242,7 @@ Menubar.Add = function ( editor ) {
 	var createDivider = UI.MenubarHelper.createDivider;
 
 	var menuConfig = [
-		createOption( 'Object3D', onObject3DOptionClick ),
+		createOption( 'Group', onGroupOptionClick ),
 		createDivider(),
 
 		createOption( 'Plane', onPlaneOptionClick ),

+ 1 - 1
examples/canvas_effects_stereo.html

@@ -54,7 +54,7 @@
 				var geometry = new THREE.BoxGeometry( 100, 100, 100 );
 				var material = new THREE.MeshNormalMaterial( { overdraw: 0.5 } );
 
-				group = new THREE.Object3D();
+				group = new THREE.Group();
 
 				for ( var i = 0; i < 200; i ++ ) {
 

+ 1 - 1
examples/canvas_geometry_earth.html

@@ -59,7 +59,7 @@
 
 				scene = new THREE.Scene();
 
-				group = new THREE.Object3D();
+				group = new THREE.Group();
 				scene.add( group );
 
 				// earth

+ 1 - 1
examples/canvas_geometry_hierarchy.html

@@ -51,7 +51,7 @@
 				var geometry = new THREE.BoxGeometry( 100, 100, 100 );
 				var material = new THREE.MeshNormalMaterial( { overdraw: 0.5 } );
 
-				group = new THREE.Object3D();
+				group = new THREE.Group();
 
 				for ( var i = 0; i < 200; i ++ ) {
 

+ 1 - 1
examples/canvas_geometry_nurbs.html

@@ -68,7 +68,7 @@
 
 				scene = new THREE.Scene();
 
-				group = new THREE.Object3D();
+				group = new THREE.Group();
 				group.position.y = 50;
 				scene.add( group );
 

+ 1 - 1
examples/canvas_geometry_shapes.html

@@ -58,7 +58,7 @@
 
 				scene = new THREE.Scene();
 
-				group = new THREE.Object3D();
+				group = new THREE.Group();
 				group.position.y = 50;
 				scene.add( group );
 

+ 1 - 1
examples/canvas_geometry_text.html

@@ -97,7 +97,7 @@
 				text.rotation.x = 0;
 				text.rotation.y = Math.PI * 2;
 
-				group = new THREE.Object3D();
+				group = new THREE.Group();
 				group.add( text );
 
 				scene.add( group );

+ 1 - 1
examples/canvas_particles_random.html

@@ -53,7 +53,7 @@
 
 				}
 
-				group = new THREE.Object3D();
+				group = new THREE.Group();
 				scene.add( group );
 
 				for ( var i = 0; i < 1000; i++ ) {

+ 1 - 1
examples/canvas_particles_shapes.html

@@ -69,7 +69,7 @@
 
 				scene = new THREE.Scene();
 
-				group = new THREE.Object3D();
+				group = new THREE.Group();
 				scene.add( group );
 
 				// Get text from hash

+ 1 - 1
examples/js/loaders/OBJMTLLoader.js

@@ -110,7 +110,7 @@ THREE.OBJMTLLoader.prototype = {
 
 		}
 
-		var group = new THREE.Object3D();
+		var group = new THREE.Group();
 		var object = group;
 
 		var geometry = new THREE.Geometry();

+ 1 - 4
examples/webgl_geometry_extrude_shapes2.html

@@ -331,10 +331,7 @@ var init3d = function(){
 	camera.position.set( 0, 0, 200 );
 
 	/// Global : group
-	group = new THREE.Object3D();
-	group.position.x = 0.0;
-	group.position.y = 0.0;
-	group.position.z = 0.0;
+	group = new THREE.Group();
 	scene.add( group );
 
 	/// direct light

+ 1 - 1
examples/webgl_geometry_hierarchy.html

@@ -51,7 +51,7 @@
 				var geometry = new THREE.BoxGeometry( 100, 100, 100 );
 				var material = new THREE.MeshNormalMaterial();
 
-				group = new THREE.Object3D();
+				group = new THREE.Group();
 
 				for ( var i = 0; i < 1000; i ++ ) {
 

+ 2 - 2
examples/webgl_geometry_normals.html

@@ -212,11 +212,11 @@
 
 				}
 
+				group = new THREE.Group();
+				scene.add( group );
 
-				group = new THREE.Object3D();
 				var mesh = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial( { color: 0xfefefe, wireframe: true, opacity: 0.5 } ) );
 				group.add( mesh );
-				scene.add( group );
 
 				var fvNames = [ 'a', 'b', 'c', 'd' ];
 

+ 1 - 1
examples/webgl_geometry_nurbs.html

@@ -75,7 +75,7 @@
 				light.position.set( 1, 1, 1 );
 				scene.add( light );
 
-				group = new THREE.Object3D();
+				group = new THREE.Group();
 				group.position.y = 50;
 				scene.add( group );
 

+ 1 - 1
examples/webgl_geometry_shapes.html

@@ -60,7 +60,7 @@
 				light.position.set( 0, 0, 1 );
 				scene.add( light );
 
-				group = new THREE.Object3D();
+				group = new THREE.Group();
 				group.position.y = 50;
 				scene.add( group );
 

+ 1 - 1
examples/webgl_geometry_subdivision.html

@@ -238,7 +238,7 @@
 
 				}
 
-				group = new THREE.Object3D();
+				group = new THREE.Group();
 				scene.add( group );
 
 				var material = new THREE.MeshBasicMaterial( { color: 0xfefefe, wireframe: true, opacity: 0.5 } );

+ 1 - 1
examples/webgl_geometry_text.html

@@ -228,7 +228,7 @@
 					new THREE.MeshPhongMaterial( { color: 0xffffff, shading: THREE.SmoothShading } ) // side
 				] );
 
-				group = new THREE.Object3D();
+				group = new THREE.Group();
 				group.position.y = 100;
 
 				scene.add( group );

+ 1 - 1
examples/webgl_geometry_text2.html

@@ -243,7 +243,7 @@
 					new THREE.MeshPhongMaterial( { color: 0xffffff, shading: THREE.SmoothShading } ) // side
 				] );
 
-				group = new THREE.Object3D();
+				group = new THREE.Group();
 				group.position.y = 100;
 
 				scene.add( group );

+ 3 - 2
examples/webgl_particles_shapes.html

@@ -185,6 +185,9 @@
 
 				var centerOffset = -0.5 * ( text3d.boundingBox.max.x - text3d.boundingBox.min.x );
 
+				group = new THREE.Group();
+				scene.add( group );
+
 				text = new THREE.Mesh( text3d, material );
 
 				// Potentially, we can extract the vertices or faces of the text to generate particles too.
@@ -197,9 +200,7 @@
 				text.rotation.x = 0;
 				text.rotation.y = Math.PI * 2;
 
-				group = new THREE.Object3D();
 				group.add( text );
-				scene.add( group );
 
 				// Create particle objects for Three.js
 

+ 1 - 1
examples/webgl_shaders_vector.html

@@ -122,7 +122,7 @@
 					bevelEnabled: false
 				};
 
-				group = new THREE.Object3D();
+				group = new THREE.Group();
 				scene.add( group );
 
 

+ 1 - 1
examples/webgl_sprites.html

@@ -57,7 +57,7 @@
 				var mapB = THREE.ImageUtils.loadTexture( "textures/sprite1.png" );
 				mapC = THREE.ImageUtils.loadTexture( "textures/sprite2.png" );
 
-				group = new THREE.Object3D();
+				group = new THREE.Group();
 
 				var materialC = new THREE.SpriteMaterial( { map: mapC, color: 0xffffff, fog: true } );
 				var materialB = new THREE.SpriteMaterial( { map: mapB, color: 0xffffff, fog: true } );

+ 11 - 0
src/objects/Group.js

@@ -0,0 +1,11 @@
+/**
+ * @author mrdoob / http://mrdoob.com/
+ */
+
+THREE.Group = function () {
+
+	THREE.Object3D.call( this );
+
+};
+
+THREE.Group.prototype = Object.create( THREE.Object3D.prototype );

+ 1 - 0
utils/build/includes/canvas.json

@@ -47,6 +47,7 @@
 	"src/materials/SpriteCanvasMaterial.js",
 	"src/textures/Texture.js",
 	"src/textures/DataTexture.js",
+	"src/objects/Group.js",
 	"src/objects/Line.js",
 	"src/objects/Mesh.js",
 	"src/objects/Bone.js",

+ 1 - 0
utils/build/includes/common.json

@@ -67,6 +67,7 @@
 	"src/textures/CubeTexture.js",
 	"src/textures/CompressedTexture.js",
 	"src/textures/DataTexture.js",
+	"src/objects/Group.js",
 	"src/objects/PointCloud.js",
 	"src/objects/Line.js",
 	"src/objects/Mesh.js",

+ 1 - 0
utils/build/includes/css3d.json

@@ -18,6 +18,7 @@
 	"src/cameras/Camera.js",
 	"src/cameras/PerspectiveCamera.js",
 	"src/lights/Light.js",
+	"src/objects/Group.js",
 	"src/objects/Bone.js",
 	"src/scenes/Scene.js",
 	"examples/js/renderers/CSS3DRenderer.js"

+ 1 - 0
utils/build/includes/webgl.json

@@ -59,6 +59,7 @@
 	"src/textures/CompressedTexture.js",
 	"src/textures/DataTexture.js",
 	"src/objects/PointCloud.js",
+	"src/objects/Group.js",
 	"src/objects/Line.js",
 	"src/objects/Mesh.js",
 	"src/objects/Bone.js",