Pārlūkot izejas kodu

Object3D cloning userData too.

Mr.doob 12 gadi atpakaļ
vecāks
revīzija
7525b2b7bc
3 mainītis faili ar 5 papildinājumiem un 1 dzēšanām
  1. 2 0
      build/three.js
  2. 1 1
      build/three.min.js
  3. 2 0
      src/core/Object3D.js

+ 2 - 0
build/three.js

@@ -6576,6 +6576,8 @@ THREE.Object3D.prototype = {
 
 		object.frustumCulled = this.frustumCulled;
 
+		object.userData = JSON.parse( JSON.stringify( this.userData ) );
+
 		for ( var i = 0; i < this.children.length; i ++ ) {
 
 			var child = this.children[ i ];

+ 1 - 1
build/three.min.js

@@ -137,7 +137,7 @@ b instanceof THREE.Scene&&b.__addObject(a)}},remove:function(a){var b=this.child
 e))return e}},getDescendants:function(a){void 0===a&&(a=[]);Array.prototype.push.apply(a,this.children);for(var b=0,c=this.children.length;b<c;b++)this.children[b].getDescendants(a);return a},updateMatrix:function(){this.matrix.setPosition(this.position);!1===this.useQuaternion?this.matrix.setRotationFromEuler(this.rotation,this.eulerOrder):this.matrix.setRotationFromQuaternion(this.quaternion);(1!==this.scale.x||1!==this.scale.y||1!==this.scale.z)&&this.matrix.scale(this.scale);this.matrixWorldNeedsUpdate=
 !0},updateMatrixWorld:function(a){!0===this.matrixAutoUpdate&&this.updateMatrix();if(!0===this.matrixWorldNeedsUpdate||!0===a)void 0===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,a=!0;for(var b=0,c=this.children.length;b<c;b++)this.children[b].updateMatrixWorld(a)},clone:function(a){void 0===a&&(a=new THREE.Object3D);a.name=this.name;a.up.copy(this.up);a.position.copy(this.position);a.rotation instanceof
 THREE.Vector3&&a.rotation.copy(this.rotation);a.eulerOrder=this.eulerOrder;a.scale.copy(this.scale);a.renderDepth=this.renderDepth;a.rotationAutoUpdate=this.rotationAutoUpdate;a.matrix.copy(this.matrix);a.matrixWorld.copy(this.matrixWorld);a.matrixRotationWorld.copy(this.matrixRotationWorld);a.matrixAutoUpdate=this.matrixAutoUpdate;a.matrixWorldNeedsUpdate=this.matrixWorldNeedsUpdate;a.quaternion.copy(this.quaternion);a.useQuaternion=this.useQuaternion;a.visible=this.visible;a.castShadow=this.castShadow;
-a.receiveShadow=this.receiveShadow;a.frustumCulled=this.frustumCulled;for(var b=0;b<this.children.length;b++)a.add(this.children[b].clone());return a}};THREE.Object3D.defaultEulerOrder="XYZ";THREE.Object3DIdCount=0;THREE.Projector=function(){function a(){if(f===h){var a=new THREE.RenderableObject;g.push(a);h++;f++;return a}return g[f++]}function b(){if(k===p){var a=new THREE.RenderableVertex;m.push(a);p++;k++;return a}return m[k++]}function c(a,b){return b.z-a.z}function d(a,b){var c=0,d=1,e=a.z+a.w,f=b.z+b.w,g=-a.z+a.w,h=-b.z+b.w;if(0<=e&&0<=f&&0<=g&&0<=h)return!0;if(0>e&&0>f||0>g&&0>h)return!1;0>e?c=Math.max(c,e/(e-f)):0>f&&(d=Math.min(d,e/(e-f)));0>g?c=Math.max(c,g/(g-h)):0>h&&(d=Math.min(d,g/(g-h)));if(d<
+a.receiveShadow=this.receiveShadow;a.frustumCulled=this.frustumCulled;a.userData=JSON.parse(JSON.stringify(this.userData));for(var b=0;b<this.children.length;b++)a.add(this.children[b].clone());return a}};THREE.Object3D.defaultEulerOrder="XYZ";THREE.Object3DIdCount=0;THREE.Projector=function(){function a(){if(f===h){var a=new THREE.RenderableObject;g.push(a);h++;f++;return a}return g[f++]}function b(){if(k===p){var a=new THREE.RenderableVertex;m.push(a);p++;k++;return a}return m[k++]}function c(a,b){return b.z-a.z}function d(a,b){var c=0,d=1,e=a.z+a.w,f=b.z+b.w,g=-a.z+a.w,h=-b.z+b.w;if(0<=e&&0<=f&&0<=g&&0<=h)return!0;if(0>e&&0>f||0>g&&0>h)return!1;0>e?c=Math.max(c,e/(e-f)):0>f&&(d=Math.min(d,e/(e-f)));0>g?c=Math.max(c,g/(g-h)):0>h&&(d=Math.min(d,g/(g-h)));if(d<
 c)return!1;a.lerp(b,c);b.lerp(a,1-d);return!0}var e,f,g=[],h=0,i,k,m=[],p=0,l,s,r=[],n=0,q,y=[],v=0,w,t,D=[],I=0,F,z,G=[],L=0,J={objects:[],sprites:[],lights:[],elements:[]},N=new THREE.Vector3,A=new THREE.Vector4,U=new THREE.Box3(new THREE.Vector3(-1,-1,-1),new THREE.Vector3(1,1,1)),H=new THREE.Box3,K=Array(3),M=Array(4),T=new THREE.Matrix4,$=new THREE.Matrix4,wa,fb=new THREE.Matrix4,B=new THREE.Matrix3,ca=new THREE.Matrix3,qa=new THREE.Vector3,ga=new THREE.Frustum,ja=new THREE.Vector4,E=new THREE.Vector4;
 this.projectVector=function(a,b){b.matrixWorldInverse.getInverse(b.matrixWorld);$.multiplyMatrices(b.projectionMatrix,b.matrixWorldInverse);return a.applyProjection($)};this.unprojectVector=function(a,b){b.projectionMatrixInverse.getInverse(b.projectionMatrix);$.multiplyMatrices(b.matrixWorld,b.projectionMatrixInverse);return a.applyProjection($)};this.pickingRay=function(a,b){a.z=-1;var c=new THREE.Vector3(a.x,a.y,1);this.unprojectVector(a,b);this.unprojectVector(c,b);c.sub(a).normalize();return new THREE.Raycaster(a,
 c)};this.projectScene=function(g,h,p,Xa){var Ba=!1,ma,fa,X,V,Y,ia,ha,na,Ka,Ya,pa,Na,Qa;z=t=q=s=0;J.elements.length=0;g.updateMatrixWorld();void 0===h.parent&&h.updateMatrixWorld();T.copy(h.matrixWorldInverse.getInverse(h.matrixWorld));$.multiplyMatrices(h.projectionMatrix,T);ca.getInverse(T);ca.transpose();ga.setFromMatrix($);f=0;J.objects.length=0;J.sprites.length=0;J.lights.length=0;var Va=function(b){for(var c=0,d=b.children.length;c<d;c++){var f=b.children[c];if(!1!==f.visible){if(f instanceof

+ 2 - 0
src/core/Object3D.js

@@ -441,6 +441,8 @@ THREE.Object3D.prototype = {
 
 		object.frustumCulled = this.frustumCulled;
 
+		object.userData = JSON.parse( JSON.stringify( this.userData ) );
+
 		for ( var i = 0; i < this.children.length; i ++ ) {
 
 			var child = this.children[ i ];