Browse Source

Added .name and .getChildByName( "objectName", doRecurse ) to Object3D. Added so scene-loader fills in .name property.

Mikael Emtinger 14 years ago
parent
commit
0198766fed
3 changed files with 45 additions and 10 deletions
  1. 10 10
      build/Three.js
  2. 34 0
      src/core/Object3D.js
  3. 1 0
      src/extras/io/SceneLoader.js

+ 10 - 10
build/Three.js

@@ -41,11 +41,11 @@ THREE.Matrix4.makeInvert3x3=function(b){var d=b.m33,c=d.m,f=b.n33*b.n22-b.n32*b.
 THREE.Matrix4.makeFrustum=function(b,d,c,f,g,h){var j;j=new THREE.Matrix4;j.n11=2*g/(d-b);j.n12=0;j.n13=(d+b)/(d-b);j.n14=0;j.n21=0;j.n22=2*g/(f-c);j.n23=(f+c)/(f-c);j.n24=0;j.n31=0;j.n32=0;j.n33=-(h+g)/(h-g);j.n34=-2*h*g/(h-g);j.n41=0;j.n42=0;j.n43=-1;j.n44=0;return j};THREE.Matrix4.makePerspective=function(b,d,c,f){var g;b=c*Math.tan(b*Math.PI/360);g=-b;return THREE.Matrix4.makeFrustum(g*d,b*d,g,b,c,f)};
 THREE.Matrix4.makeFrustum=function(b,d,c,f,g,h){var j;j=new THREE.Matrix4;j.n11=2*g/(d-b);j.n12=0;j.n13=(d+b)/(d-b);j.n14=0;j.n21=0;j.n22=2*g/(f-c);j.n23=(f+c)/(f-c);j.n24=0;j.n31=0;j.n32=0;j.n33=-(h+g)/(h-g);j.n34=-2*h*g/(h-g);j.n41=0;j.n42=0;j.n43=-1;j.n44=0;return j};THREE.Matrix4.makePerspective=function(b,d,c,f){var g;b=c*Math.tan(b*Math.PI/360);g=-b;return THREE.Matrix4.makeFrustum(g*d,b*d,g,b,c,f)};
 THREE.Matrix4.makeOrtho=function(b,d,c,f,g,h){var j,k,m,o;j=new THREE.Matrix4;k=d-b;m=c-f;o=h-g;j.n11=2/k;j.n12=0;j.n13=0;j.n14=-((d+b)/k);j.n21=0;j.n22=2/m;j.n23=0;j.n24=-((c+f)/m);j.n31=0;j.n32=0;j.n33=-2/o;j.n34=-((h+g)/o);j.n41=0;j.n42=0;j.n43=0;j.n44=1;return j};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;
 THREE.Matrix4.makeOrtho=function(b,d,c,f,g,h){var j,k,m,o;j=new THREE.Matrix4;k=d-b;m=c-f;o=h-g;j.n11=2/k;j.n12=0;j.n13=0;j.n14=-((d+b)/k);j.n21=0;j.n22=2/m;j.n23=0;j.n24=-((c+f)/m);j.n31=0;j.n32=0;j.n33=-2/o;j.n34=-((h+g)/o);j.n41=0;j.n42=0;j.n43=0;j.n44=1;return j};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;
 THREE.Object3D=function(){this.parent=undefined;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixAutoUpdate=!0;this.matrixWorldNeedsUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=
 THREE.Object3D=function(){this.parent=undefined;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixAutoUpdate=!0;this.matrixWorldNeedsUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=
-!0;this._vector=new THREE.Vector3};
-THREE.Object3D.prototype={translate:function(b,d){this.matrix.rotateAxis(d);this.position.addSelf(d.multiplyScalar(b))},translateX:function(b){this.translate(b,this._vector.set(1,0,0))},translateY:function(b){this.translate(b,this._vector.set(0,1,0))},translateZ:function(b){this.translate(b,this._vector.set(0,0,1))},lookAt:function(b){this.matrix.lookAt(b,this.position,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},addChild:function(b){if(this.children.indexOf(b)===-1){b.parent!==
-undefined&&b.parent.removeChild(b);b.parent=this;this.children.push(b);for(var d=this;d instanceof THREE.Scene===!1&&d!==undefined;)d=d.parent;d!==undefined&&d.addChildRecurse(b)}},removeChild:function(b){var d=this.children.indexOf(b);if(d!==-1){b.parent=undefined;this.children.splice(d,1)}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation);if(this.scale.x!==1||this.scale.y!==
-1||this.scale.z!==1){this.matrix.scale(this.scale);this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z))}this.matrixWorldNeedsUpdate=!0},update:function(b,d,c){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||d){b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale);this.matrixWorldNeedsUpdate=!1;d=!0}b=0;for(var f=this.children.length;b<f;b++)this.children[b].update(this.matrixWorld,
-d,c)}};THREE.Quaternion=function(b,d,c,f){this.set(b||0,d||0,c||0,f!==undefined?f:1)};
+!0;this._vector=new THREE.Vector3;this.name=""};
+THREE.Object3D.prototype={translate:function(b,d){this.matrix.rotateAxis(d);this.position.addSelf(d.multiplyScalar(b))},translateX:function(b){this.translate(b,this._vector.set(1,0,0))},translateY:function(b){this.translate(b,this._vector.set(0,1,0))},translateZ:function(b){this.translate(b,this._vector.set(0,0,1))},lookAt:function(b){this.matrix.lookAt(b,this.position,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},addChild:function(b){if(this.children.indexOf(b)===
+-1){b.parent!==undefined&&b.parent.removeChild(b);b.parent=this;this.children.push(b);for(var d=this;d instanceof THREE.Scene===!1&&d!==undefined;)d=d.parent;d!==undefined&&d.addChildRecurse(b)}},removeChild:function(b){var d=this.children.indexOf(b);if(d!==-1){b.parent=undefined;this.children.splice(d,1)}},getChildByName:function(b,d){var c,f,g;c=0;for(f=this.children.length;c<f;c++){g=this.children[c];if(g.name===b)return g;if(d){g=g.getChildByName(b,d);if(g!==undefined)return g}}},updateMatrix:function(){this.matrix.setPosition(this.position);
+this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation);if(this.scale.x!==1||this.scale.y!==1||this.scale.z!==1){this.matrix.scale(this.scale);this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z))}this.matrixWorldNeedsUpdate=!0},update:function(b,d,c){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||d){b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix);
+this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale);this.matrixWorldNeedsUpdate=!1;d=!0}b=0;for(var f=this.children.length;b<f;b++)this.children[b].update(this.matrixWorld,d,c)}};THREE.Quaternion=function(b,d,c,f){this.set(b||0,d||0,c||0,f!==undefined?f:1)};
 THREE.Quaternion.prototype={set:function(b,d,c,f){this.x=b;this.y=d;this.z=c;this.w=f;return this},copy:function(b){this.x=b.x;this.y=b.y;this.z=b.z;this.w=b.w;return this},setFromEuler:function(b){var d=0.5*Math.PI/360,c=b.x*d,f=b.y*d,g=b.z*d;b=Math.cos(f);f=Math.sin(f);d=Math.cos(-g);g=Math.sin(-g);var h=Math.cos(c);c=Math.sin(c);var j=b*d,k=f*g;this.w=j*h-k*c;this.x=j*c+k*h;this.y=f*d*h+b*g*c;this.z=b*g*h-f*d*c;return this},setFromAxisAngle:function(b,d){var c=d/2,f=Math.sin(c);this.x=b.x*f;this.y=
 THREE.Quaternion.prototype={set:function(b,d,c,f){this.x=b;this.y=d;this.z=c;this.w=f;return this},copy:function(b){this.x=b.x;this.y=b.y;this.z=b.z;this.w=b.w;return this},setFromEuler:function(b){var d=0.5*Math.PI/360,c=b.x*d,f=b.y*d,g=b.z*d;b=Math.cos(f);f=Math.sin(f);d=Math.cos(-g);g=Math.sin(-g);var h=Math.cos(c);c=Math.sin(c);var j=b*d,k=f*g;this.w=j*h-k*c;this.x=j*c+k*h;this.y=f*d*h+b*g*c;this.z=b*g*h-f*d*c;return this},setFromAxisAngle:function(b,d){var c=d/2,f=Math.sin(c);this.x=b.x*f;this.y=
 b.y*f;this.z=b.z*f;this.w=Math.cos(c);return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var b=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(b==0)this.w=this.z=this.y=this.x=0;else{b=1/b;this.x*=b;this.y*=b;this.z*=b;this.w*=b}return this},
 b.y*f;this.z=b.z*f;this.w=Math.cos(c);return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var b=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(b==0)this.w=this.z=this.y=this.x=0;else{b=1/b;this.x*=b;this.y*=b;this.z*=b;this.w*=b}return this},
 multiplySelf:function(b){var d=this.x,c=this.y,f=this.z,g=this.w,h=b.x,j=b.y,k=b.z;b=b.w;this.x=d*b+g*h+c*k-f*j;this.y=c*b+g*j+f*h-d*k;this.z=f*b+g*k+d*j-c*h;this.w=g*b-d*h-c*j-f*k;return this},multiply:function(b,d){this.x=b.x*d.w+b.y*d.z-b.z*d.y+b.w*d.x;this.y=-b.x*d.z+b.y*d.w+b.z*d.x+b.w*d.y;this.z=b.x*d.y-b.y*d.x+b.z*d.w+b.w*d.z;this.w=-b.x*d.x-b.y*d.y-b.z*d.z+b.w*d.w;return this},multiplyVector3:function(b,d){d||(d=b);var c=b.x,f=b.y,g=b.z,h=this.x,j=this.y,k=this.z,m=this.w,o=m*c+j*g-k*f,p=
 multiplySelf:function(b){var d=this.x,c=this.y,f=this.z,g=this.w,h=b.x,j=b.y,k=b.z;b=b.w;this.x=d*b+g*h+c*k-f*j;this.y=c*b+g*j+f*h-d*k;this.z=f*b+g*k+d*j-c*h;this.w=g*b-d*h-c*j-f*k;return this},multiply:function(b,d){this.x=b.x*d.w+b.y*d.z-b.z*d.y+b.w*d.x;this.y=-b.x*d.z+b.y*d.w+b.z*d.x+b.w*d.y;this.z=b.x*d.y-b.y*d.x+b.z*d.w+b.w*d.z;this.w=-b.x*d.x-b.y*d.y-b.z*d.z+b.w*d.w;return this},multiplyVector3:function(b,d){d||(d=b);var c=b.x,f=b.y,g=b.z,h=this.x,j=this.y,k=this.z,m=this.w,o=m*c+j*g-k*f,p=
@@ -458,11 +458,11 @@ P)u(S);return Ba-R})(Xa);(function(R){var S,P=B.vertex_index_bytes*4+B.material_
 c,f,g,null,null,b.materials[h]))},f3n:function(b,d,c,f,g,h,j,k,m){h=b.materials[h];var o=d[k*3],p=d[k*3+1];k=d[k*3+2];var t=d[m*3],z=d[m*3+1];m=d[m*3+2];b.faces.push(new THREE.Face3(c,f,g,[new THREE.Vector3(d[j*3],d[j*3+1],d[j*3+2]),new THREE.Vector3(o,p,k),new THREE.Vector3(t,z,m)],null,h))},f4n:function(b,d,c,f,g,h,j,k,m,o,p){j=b.materials[j];var t=d[m*3],z=d[m*3+1];m=d[m*3+2];var u=d[o*3],A=d[o*3+1];o=d[o*3+2];var E=d[p*3],H=d[p*3+1];p=d[p*3+2];b.faces.push(new THREE.Face4(c,f,g,h,[new THREE.Vector3(d[k*
 c,f,g,null,null,b.materials[h]))},f3n:function(b,d,c,f,g,h,j,k,m){h=b.materials[h];var o=d[k*3],p=d[k*3+1];k=d[k*3+2];var t=d[m*3],z=d[m*3+1];m=d[m*3+2];b.faces.push(new THREE.Face3(c,f,g,[new THREE.Vector3(d[j*3],d[j*3+1],d[j*3+2]),new THREE.Vector3(o,p,k),new THREE.Vector3(t,z,m)],null,h))},f4n:function(b,d,c,f,g,h,j,k,m,o,p){j=b.materials[j];var t=d[m*3],z=d[m*3+1];m=d[m*3+2];var u=d[o*3],A=d[o*3+1];o=d[o*3+2];var E=d[p*3],H=d[p*3+1];p=d[p*3+2];b.faces.push(new THREE.Face4(c,f,g,h,[new THREE.Vector3(d[k*
 3],d[k*3+1],d[k*3+2]),new THREE.Vector3(t,z,m),new THREE.Vector3(u,A,o),new THREE.Vector3(E,H,p)],null,j))},uv3:function(b,d,c,f,g,h,j){var k=[];k.push(new THREE.UV(d,c));k.push(new THREE.UV(f,g));k.push(new THREE.UV(h,j));b.push(k)},uv4:function(b,d,c,f,g,h,j,k,m){var o=[];o.push(new THREE.UV(d,c));o.push(new THREE.UV(f,g));o.push(new THREE.UV(h,j));o.push(new THREE.UV(k,m));b.push(o)}};THREE.SceneLoader=function(){};
 3],d[k*3+1],d[k*3+2]),new THREE.Vector3(t,z,m),new THREE.Vector3(u,A,o),new THREE.Vector3(E,H,p)],null,j))},uv3:function(b,d,c,f,g,h,j){var k=[];k.push(new THREE.UV(d,c));k.push(new THREE.UV(f,g));k.push(new THREE.UV(h,j));b.push(k)},uv4:function(b,d,c,f,g,h,j,k,m){var o=[];o.push(new THREE.UV(d,c));o.push(new THREE.UV(f,g));o.push(new THREE.UV(h,j));o.push(new THREE.UV(k,m));b.push(o)}};THREE.SceneLoader=function(){};
 THREE.SceneLoader.prototype={load:function(b,d,c,f){var g=new Worker(b);g.postMessage(0);var h=THREE.Loader.prototype.extractUrlbase(b);g.onmessage=function(j){function k(wa,ca){return ca=="relativeToHTML"?wa:h+"/"+wa}function m(){for(u in ga.objects)if(!ka.objects[u]){W=ga.objects[u];if(O=ka.geometries[W.geometry]){pa=[];for(sa=0;sa<W.materials.length;sa++)pa[sa]=ka.materials[W.materials[sa]];B=W.position;r=W.rotation;q=W.quaternion;s=W.scale;q=0;pa.length==0&&(pa[0]=new THREE.MeshFaceMaterial);
 THREE.SceneLoader.prototype={load:function(b,d,c,f){var g=new Worker(b);g.postMessage(0);var h=THREE.Loader.prototype.extractUrlbase(b);g.onmessage=function(j){function k(wa,ca){return ca=="relativeToHTML"?wa:h+"/"+wa}function m(){for(u in ga.objects)if(!ka.objects[u]){W=ga.objects[u];if(O=ka.geometries[W.geometry]){pa=[];for(sa=0;sa<W.materials.length;sa++)pa[sa]=ka.materials[W.materials[sa]];B=W.position;r=W.rotation;q=W.quaternion;s=W.scale;q=0;pa.length==0&&(pa[0]=new THREE.MeshFaceMaterial);
-pa.length>1&&(pa=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(O,pa);object.position.set(B[0],B[1],B[2]);if(q){object.quaternion.set(q[0],q[1],q[2],q[3]);object.useQuaternion=!0}else object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=W.visible;ka.scene.addObject(object);ka.objects[u]=object;if(W.meshCollider){var wa=THREE.CollisionUtils.MeshColliderWBox(object);THREE.Collisions.colliders.push(wa)}}}}function o(wa){return function(ca){ka.geometries[wa]=ca;m();
-e-=1;p()}}function p(){f({total_models:Da,total_textures:Aa,loaded_models:Da-e,loaded_textures:Aa-oa},ka);e==0&&oa==0&&c(ka)}var t,z,u,A,E,H,J,W,B,U,N,O,ua,la,pa,ga,ha,e,oa,Da,Aa,ka;ga=j.data;j=new THREE.BinaryLoader;ha=new THREE.JSONLoader;oa=e=0;ka={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};if(ga.transform){var fa=ga.transform.position;U=ga.transform.rotation;var va=ga.transform.scale;fa&&ka.scene.position.set(fa[0],fa[1],fa[2]);U&&ka.scene.rotation.set(U[0],
-U[1],U[2]);va&&ka.scene.scale.set(va[0],va[1],va[2]);(fa||U||va)&&ka.scene.updateMatrix()}fa=function(){oa-=1;p()};for(E in ga.cameras){U=ga.cameras[E];if(U.type=="perspective")ua=new THREE.Camera(U.fov,U.aspect,U.near,U.far);else if(U.type=="ortho"){ua=new THREE.Camera;ua.projectionMatrix=THREE.Matrix4.makeOrtho(U.left,U.right,U.top,U.bottom,U.near,U.far)}B=U.position;U=U.target;ua.position.set(B[0],B[1],B[2]);ua.target.position.set(U[0],U[1],U[2]);ka.cameras[E]=ua}for(A in ga.lights){E=ga.lights[A];
-ua=E.color!==undefined?E.color:16777215;U=E.intensity!==undefined?E.intensity:1;if(E.type=="directional"){B=E.direction;light=new THREE.DirectionalLight(ua,U);light.position.set(B[0],B[1],B[2]);light.position.normalize()}else if(E.type=="point"){B=E.position;light=new THREE.PointLight(ua,U);light.position.set(B[0],B[1],B[2])}ka.scene.addLight(light);ka.lights[A]=light}for(H in ga.fogs){A=ga.fogs[H];if(A.type=="linear")la=new THREE.Fog(0,A.near,A.far);else A.type=="exp2"&&(la=new THREE.FogExp2(0,A.density));
-U=A.color;la.color.setRGB(U[0],U[1],U[2]);ka.fogs[H]=la}if(ka.cameras&&ga.defaults.camera)ka.currentCamera=ka.cameras[ga.defaults.camera];if(ka.fogs&&ga.defaults.fog)ka.scene.fog=ka.fogs[ga.defaults.fog];U=ga.defaults.bgcolor;ka.bgColor=new THREE.Color;ka.bgColor.setRGB(U[0],U[1],U[2]);ka.bgColorAlpha=ga.defaults.bgalpha;for(t in ga.geometries){H=ga.geometries[t];if(H.type=="bin_mesh"||H.type=="ascii_mesh")e+=1}Da=e;for(t in ga.geometries){H=ga.geometries[t];if(H.type=="cube"){O=new THREE.Cube(H.width,
+pa.length>1&&(pa=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(O,pa);object.name=u;object.position.set(B[0],B[1],B[2]);if(q){object.quaternion.set(q[0],q[1],q[2],q[3]);object.useQuaternion=!0}else object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=W.visible;ka.scene.addObject(object);ka.objects[u]=object;if(W.meshCollider){var wa=THREE.CollisionUtils.MeshColliderWBox(object);THREE.Collisions.colliders.push(wa)}}}}function o(wa){return function(ca){ka.geometries[wa]=
+ca;m();e-=1;p()}}function p(){f({total_models:Da,total_textures:Aa,loaded_models:Da-e,loaded_textures:Aa-oa},ka);e==0&&oa==0&&c(ka)}var t,z,u,A,E,H,J,W,B,U,N,O,ua,la,pa,ga,ha,e,oa,Da,Aa,ka;ga=j.data;j=new THREE.BinaryLoader;ha=new THREE.JSONLoader;oa=e=0;ka={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};if(ga.transform){var fa=ga.transform.position;U=ga.transform.rotation;var va=ga.transform.scale;fa&&ka.scene.position.set(fa[0],fa[1],fa[2]);
+U&&ka.scene.rotation.set(U[0],U[1],U[2]);va&&ka.scene.scale.set(va[0],va[1],va[2]);(fa||U||va)&&ka.scene.updateMatrix()}fa=function(){oa-=1;p()};for(E in ga.cameras){U=ga.cameras[E];if(U.type=="perspective")ua=new THREE.Camera(U.fov,U.aspect,U.near,U.far);else if(U.type=="ortho"){ua=new THREE.Camera;ua.projectionMatrix=THREE.Matrix4.makeOrtho(U.left,U.right,U.top,U.bottom,U.near,U.far)}B=U.position;U=U.target;ua.position.set(B[0],B[1],B[2]);ua.target.position.set(U[0],U[1],U[2]);ka.cameras[E]=ua}for(A in ga.lights){E=
+ga.lights[A];ua=E.color!==undefined?E.color:16777215;U=E.intensity!==undefined?E.intensity:1;if(E.type=="directional"){B=E.direction;light=new THREE.DirectionalLight(ua,U);light.position.set(B[0],B[1],B[2]);light.position.normalize()}else if(E.type=="point"){B=E.position;light=new THREE.PointLight(ua,U);light.position.set(B[0],B[1],B[2])}ka.scene.addLight(light);ka.lights[A]=light}for(H in ga.fogs){A=ga.fogs[H];if(A.type=="linear")la=new THREE.Fog(0,A.near,A.far);else A.type=="exp2"&&(la=new THREE.FogExp2(0,
+A.density));U=A.color;la.color.setRGB(U[0],U[1],U[2]);ka.fogs[H]=la}if(ka.cameras&&ga.defaults.camera)ka.currentCamera=ka.cameras[ga.defaults.camera];if(ka.fogs&&ga.defaults.fog)ka.scene.fog=ka.fogs[ga.defaults.fog];U=ga.defaults.bgcolor;ka.bgColor=new THREE.Color;ka.bgColor.setRGB(U[0],U[1],U[2]);ka.bgColorAlpha=ga.defaults.bgalpha;for(t in ga.geometries){H=ga.geometries[t];if(H.type=="bin_mesh"||H.type=="ascii_mesh")e+=1}Da=e;for(t in ga.geometries){H=ga.geometries[t];if(H.type=="cube"){O=new THREE.Cube(H.width,
 H.height,H.depth,H.segmentsWidth,H.segmentsHeight,H.segmentsDepth,null,H.flipped,H.sides);ka.geometries[t]=O}else if(H.type=="plane"){O=new THREE.Plane(H.width,H.height,H.segmentsWidth,H.segmentsHeight);ka.geometries[t]=O}else if(H.type=="sphere"){O=new THREE.Sphere(H.radius,H.segmentsWidth,H.segmentsHeight);ka.geometries[t]=O}else if(H.type=="cylinder"){O=new THREE.Cylinder(H.numSegs,H.topRad,H.botRad,H.height,H.topOffset,H.botOffset);ka.geometries[t]=O}else if(H.type=="torus"){O=new THREE.Torus(H.radius,
 H.height,H.depth,H.segmentsWidth,H.segmentsHeight,H.segmentsDepth,null,H.flipped,H.sides);ka.geometries[t]=O}else if(H.type=="plane"){O=new THREE.Plane(H.width,H.height,H.segmentsWidth,H.segmentsHeight);ka.geometries[t]=O}else if(H.type=="sphere"){O=new THREE.Sphere(H.radius,H.segmentsWidth,H.segmentsHeight);ka.geometries[t]=O}else if(H.type=="cylinder"){O=new THREE.Cylinder(H.numSegs,H.topRad,H.botRad,H.height,H.topOffset,H.botOffset);ka.geometries[t]=O}else if(H.type=="torus"){O=new THREE.Torus(H.radius,
 H.tube,H.segmentsR,H.segmentsT);ka.geometries[t]=O}else if(H.type=="icosahedron"){O=new THREE.Icosahedron(H.subdivisions);ka.geometries[t]=O}else if(H.type=="bin_mesh")j.load({model:k(H.url,ga.urlBaseType),callback:o(t)});else H.type=="ascii_mesh"&&ha.load({model:k(H.url,ga.urlBaseType),callback:o(t)})}for(J in ga.textures){t=ga.textures[J];oa+=t.url instanceof Array?t.url.length:1}Aa=oa;for(J in ga.textures){t=ga.textures[J];if(t.mapping!=undefined&&THREE[t.mapping]!=undefined)t.mapping=new THREE[t.mapping];
 H.tube,H.segmentsR,H.segmentsT);ka.geometries[t]=O}else if(H.type=="icosahedron"){O=new THREE.Icosahedron(H.subdivisions);ka.geometries[t]=O}else if(H.type=="bin_mesh")j.load({model:k(H.url,ga.urlBaseType),callback:o(t)});else H.type=="ascii_mesh"&&ha.load({model:k(H.url,ga.urlBaseType),callback:o(t)})}for(J in ga.textures){t=ga.textures[J];oa+=t.url instanceof Array?t.url.length:1}Aa=oa;for(J in ga.textures){t=ga.textures[J];if(t.mapping!=undefined&&THREE[t.mapping]!=undefined)t.mapping=new THREE[t.mapping];
 if(t.url instanceof Array){H=[];for(var sa=0;sa<t.url.length;sa++)H[sa]=k(t.url[sa],ga.urlBaseType);H=THREE.ImageUtils.loadTextureCube(H,t.mapping,fa)}else{H=THREE.ImageUtils.loadTexture(k(t.url,ga.urlBaseType),t.mapping,fa);if(THREE[t.minFilter]!=undefined)H.minFilter=THREE[t.minFilter];if(THREE[t.magFilter]!=undefined)H.magFilter=THREE[t.magFilter]}ka.textures[J]=H}for(z in ga.materials){J=ga.materials[z];for(N in J.parameters)if(N=="envMap"||N=="map"||N=="lightMap")J.parameters[N]=ka.textures[J.parameters[N]];
 if(t.url instanceof Array){H=[];for(var sa=0;sa<t.url.length;sa++)H[sa]=k(t.url[sa],ga.urlBaseType);H=THREE.ImageUtils.loadTextureCube(H,t.mapping,fa)}else{H=THREE.ImageUtils.loadTexture(k(t.url,ga.urlBaseType),t.mapping,fa);if(THREE[t.minFilter]!=undefined)H.minFilter=THREE[t.minFilter];if(THREE[t.magFilter]!=undefined)H.magFilter=THREE[t.magFilter]}ka.textures[J]=H}for(z in ga.materials){J=ga.materials[z];for(N in J.parameters)if(N=="envMap"||N=="map"||N=="lightMap")J.parameters[N]=ka.textures[J.parameters[N]];

+ 34 - 0
src/core/Object3D.js

@@ -33,6 +33,8 @@ THREE.Object3D = function() {
 	this.visible = true;
 	this.visible = true;
 
 
 	this._vector = new THREE.Vector3();
 	this._vector = new THREE.Vector3();
+	
+	this.name = "";
 
 
 };
 };
 
 
@@ -123,6 +125,38 @@ THREE.Object3D.prototype = {
 		}
 		}
 
 
 	},
 	},
+	
+	getChildByName: function ( name, doRecurse ) {
+		
+		var c, cl, child, recurseResult;
+		
+		for( c = 0, cl = this.children.length; c < cl; c++ ) {
+			
+			child = this.children[ c ];
+			
+			if( child.name === name ) {
+				
+				return child;
+				
+			}
+			
+			if( doRecurse ) {
+				
+				recurseResult = child.getChildByName( name, doRecurse );
+				
+				if( recurseResult !== undefined ) {
+					
+					return recurseResult;
+					
+				}
+				
+			}
+			
+		}
+		
+		return undefined;
+		
+	},
 
 
 	updateMatrix: function () {
 	updateMatrix: function () {
 
 

+ 1 - 0
src/extras/io/SceneLoader.js

@@ -125,6 +125,7 @@ THREE.SceneLoader.prototype = {
 							}
 							}
 
 
 							object = new THREE.Mesh( geometry, materials );
 							object = new THREE.Mesh( geometry, materials );
+							object.name = dd;
 							object.position.set( p[0], p[1], p[2] );
 							object.position.set( p[0], p[1], p[2] );
 
 
 							if ( q ) {
 							if ( q ) {