提交 802e589c 编写于 作者: D dubejf

CloneProperties renamed _copyFrom, swap src / dest arg order

上级 faa8745f
...@@ -22,7 +22,7 @@ THREE.SpriteCanvasMaterial.prototype.clone = function () { ...@@ -22,7 +22,7 @@ THREE.SpriteCanvasMaterial.prototype.clone = function () {
var material = new THREE.SpriteCanvasMaterial(); var material = new THREE.SpriteCanvasMaterial();
THREE.Material.prototype.cloneProperties.call( this, material ); THREE.Material.prototype._copyFrom.call( material, this );
material.color.copy( this.color ); material.color.copy( this.color );
material.program = this.program; material.program = this.program;
......
...@@ -741,7 +741,7 @@ THREE.ProxyGeometry.prototype.computeBoundingBox = function () { ...@@ -741,7 +741,7 @@ THREE.ProxyGeometry.prototype.computeBoundingBox = function () {
}; };
THREE.ProxyGeometry.prototype.clone = function () { THREE.ProxyGeometry.prototype.clone = function () {
var buff = THREE.BufferGeometry.prototype.cloneProperties.call(this); var buff = THREE.BufferGeometry.prototype.clone.call( this );
var geo = new THREE.ProxyGeometry(); var geo = new THREE.ProxyGeometry();
geo.attributes = buff.attributes; geo.attributes = buff.attributes;
geo.offsets = buff.drawcalls; geo.offsets = buff.drawcalls;
......
...@@ -53,17 +53,17 @@ THREE.Camera.prototype.lookAt = function () { ...@@ -53,17 +53,17 @@ THREE.Camera.prototype.lookAt = function () {
THREE.Camera.prototype.clone = function () { THREE.Camera.prototype.clone = function () {
var camera = new THREE.Camera(); var camera = new THREE.Camera();
return this.cloneProperties( camera ); return camera._copyFrom( this );
}; };
THREE.Camera.prototype.cloneProperties = function ( camera ) { THREE.Camera.prototype._copyFrom = function ( source ) {
THREE.Object3D.prototype.cloneProperties.call( this, camera ); THREE.Object3D.prototype._copyFrom.call( this, source );
camera.matrixWorldInverse.copy( this.matrixWorldInverse ); this.matrixWorldInverse.copy( source.matrixWorldInverse );
camera.projectionMatrix.copy( this.projectionMatrix ); this.projectionMatrix.copy( source.projectionMatrix );
return camera; return this;
}; };
...@@ -40,7 +40,7 @@ THREE.OrthographicCamera.prototype.clone = function () { ...@@ -40,7 +40,7 @@ THREE.OrthographicCamera.prototype.clone = function () {
var camera = new THREE.OrthographicCamera(); var camera = new THREE.OrthographicCamera();
THREE.Camera.prototype.cloneProperties.call( this, camera ); THREE.Camera.prototype._copyFrom.call( camera, this );
camera.zoom = this.zoom; camera.zoom = this.zoom;
......
...@@ -126,7 +126,7 @@ THREE.PerspectiveCamera.prototype.clone = function () { ...@@ -126,7 +126,7 @@ THREE.PerspectiveCamera.prototype.clone = function () {
var camera = new THREE.PerspectiveCamera(); var camera = new THREE.PerspectiveCamera();
THREE.Camera.prototype.cloneProperties.call( this, camera ); THREE.Camera.prototype._copyFrom.call( camera, this );
camera.zoom = this.zoom; camera.zoom = this.zoom;
......
...@@ -1108,28 +1108,28 @@ THREE.BufferGeometry.prototype = { ...@@ -1108,28 +1108,28 @@ THREE.BufferGeometry.prototype = {
clone: function () { clone: function () {
var geometry = new THREE.BufferGeometry(); var geometry = new THREE.BufferGeometry();
return this.cloneProperties( geometry ); return geometry._copyFrom( this );
}, },
cloneProperties: function ( geometry ) { _copyFrom: function ( source ) {
for ( var attr in this.attributes ) { for ( var attr in source.attributes ) {
var sourceAttr = this.attributes[ attr ]; var sourceAttr = source.attributes[ attr ];
geometry.addAttribute( attr, sourceAttr.clone() ); this.addAttribute( attr, sourceAttr.clone() );
} }
for ( var i = 0, il = this.drawcalls.length; i < il; i ++ ) { for ( var i = 0, il = source.drawcalls.length; i < il; i ++ ) {
var offset = this.drawcalls[ i ]; var offset = source.drawcalls[ i ];
geometry.addDrawCall( offset.start, offset.count, offset.index ); this.addDrawCall( offset.start, offset.count, offset.index );
} }
return geometry; return this;
}, },
......
...@@ -1049,39 +1049,39 @@ THREE.Geometry.prototype = { ...@@ -1049,39 +1049,39 @@ THREE.Geometry.prototype = {
clone: function () { clone: function () {
var geometry = new THREE.Geometry(); var geometry = new THREE.Geometry();
return this.cloneProperties( geometry ); return geometry._copyFrom( this );
}, },
cloneProperties: function ( geometry ) { _copyFrom: function ( source ) {
geometry.vertices = []; this.vertices = [];
geometry.faces = []; this.faces = [];
geometry.faceVertexUvs = [ [] ]; this.faceVertexUvs = [ [] ];
var vertices = this.vertices; var vertices = source.vertices;
for ( var i = 0, il = vertices.length; i < il; i ++ ) { for ( var i = 0, il = vertices.length; i < il; i ++ ) {
geometry.vertices.push( vertices[ i ].clone() ); this.vertices.push( vertices[ i ].clone() );
} }
var faces = this.faces; var faces = source.faces;
for ( var i = 0, il = faces.length; i < il; i ++ ) { for ( var i = 0, il = faces.length; i < il; i ++ ) {
geometry.faces.push( faces[ i ].clone() ); this.faces.push( faces[ i ].clone() );
} }
for ( var i = 0, il = this.faceVertexUvs.length; i < il; i ++ ) { for ( var i = 0, il = source.faceVertexUvs.length; i < il; i ++ ) {
var faceVertexUvs = this.faceVertexUvs[ i ]; var faceVertexUvs = source.faceVertexUvs[ i ];
if ( geometry.faceVertexUvs[ i ] === undefined ) { if ( this.faceVertexUvs[ i ] === undefined ) {
geometry.faceVertexUvs[ i ] = []; this.faceVertexUvs[ i ] = [];
} }
...@@ -1097,13 +1097,13 @@ THREE.Geometry.prototype = { ...@@ -1097,13 +1097,13 @@ THREE.Geometry.prototype = {
} }
geometry.faceVertexUvs[ i ].push( uvsCopy ); this.faceVertexUvs[ i ].push( uvsCopy );
} }
} }
return geometry; return this;
}, },
......
...@@ -662,52 +662,52 @@ THREE.Object3D.prototype = { ...@@ -662,52 +662,52 @@ THREE.Object3D.prototype = {
clone: function ( recursive ) { clone: function ( recursive ) {
var object = new THREE.Object3D(); var object = new THREE.Object3D();
return this.cloneProperties( object, recursive ); return object._copyFrom( this, recursive );
}, },
cloneProperties: function ( object, recursive ) { _copyFrom: function ( source, recursive ) {
if ( recursive === undefined ) recursive = true; if ( recursive === undefined ) recursive = true;
object.name = this.name; this.name = source.name;
object.up.copy( this.up ); this.up.copy( source.up );
object.position.copy( this.position ); this.position.copy( source.position );
object.quaternion.copy( this.quaternion ); this.quaternion.copy( source.quaternion );
object.scale.copy( this.scale ); this.scale.copy( source.scale );
object.rotationAutoUpdate = this.rotationAutoUpdate; this.rotationAutoUpdate = source.rotationAutoUpdate;
object.matrix.copy( this.matrix ); this.matrix.copy( source.matrix );
object.matrixWorld.copy( this.matrixWorld ); this.matrixWorld.copy( source.matrixWorld );
object.matrixAutoUpdate = this.matrixAutoUpdate; this.matrixAutoUpdate = source.matrixAutoUpdate;
object.matrixWorldNeedsUpdate = this.matrixWorldNeedsUpdate; this.matrixWorldNeedsUpdate = source.matrixWorldNeedsUpdate;
object.visible = this.visible; this.visible = source.visible;
object.castShadow = this.castShadow; this.castShadow = source.castShadow;
object.receiveShadow = this.receiveShadow; this.receiveShadow = source.receiveShadow;
object.frustumCulled = this.frustumCulled; this.frustumCulled = source.frustumCulled;
object.renderOrder = this.renderOrder; this.renderOrder = source.renderOrder;
object.userData = JSON.parse( JSON.stringify( this.userData ) ); this.userData = JSON.parse( JSON.stringify( source.userData ) );
if ( recursive === true ) { if ( recursive === true ) {
for ( var i = 0; i < this.children.length; i ++ ) { for ( var i = 0; i < source.children.length; i ++ ) {
var child = this.children[ i ]; var child = source.children[ i ];
object.add( child.clone() ); this.add( child.clone() );
} }
} }
return object; return this;
} }
......
...@@ -77,7 +77,7 @@ THREE.CircleBufferGeometry.prototype.clone = function () { ...@@ -77,7 +77,7 @@ THREE.CircleBufferGeometry.prototype.clone = function () {
this.parameters.thetaLength this.parameters.thetaLength
); );
THREE.BufferGeometry.prototype.cloneProperties.call( this, geometry ); THREE.BufferGeometry.prototype._copyFrom.call( geometry, this );
return geometry; return geometry;
......
...@@ -64,7 +64,7 @@ THREE.DodecahedronGeometry.prototype.clone = function () { ...@@ -64,7 +64,7 @@ THREE.DodecahedronGeometry.prototype.clone = function () {
this.parameters.detail this.parameters.detail
); );
THREE.PolyhedronGeometry.prototype.cloneProperties.call( this, geometry ); THREE.PolyhedronGeometry.prototype._copyFrom.call( geometry, this );
return geometry; return geometry;
......
...@@ -39,7 +39,7 @@ THREE.IcosahedronGeometry.prototype.clone = function () { ...@@ -39,7 +39,7 @@ THREE.IcosahedronGeometry.prototype.clone = function () {
this.parameters.detail this.parameters.detail
); );
THREE.PolyhedronGeometry.prototype.cloneProperties.call( this, geometry ); THREE.PolyhedronGeometry.prototype._copyFrom.call( geometry, this );
return geometry; return geometry;
......
...@@ -32,7 +32,7 @@ THREE.OctahedronGeometry.prototype.clone = function () { ...@@ -32,7 +32,7 @@ THREE.OctahedronGeometry.prototype.clone = function () {
this.parameters.detail this.parameters.detail
); );
THREE.PolyhedronGeometry.prototype.cloneProperties.call( this, geometry ); THREE.PolyhedronGeometry.prototype._copyFrom.call( geometry, this );
return geometry; return geometry;
......
...@@ -104,7 +104,7 @@ THREE.PlaneBufferGeometry.prototype.clone = function () { ...@@ -104,7 +104,7 @@ THREE.PlaneBufferGeometry.prototype.clone = function () {
this.parameters.heightSegments this.parameters.heightSegments
); );
THREE.BufferGeometry.prototype.cloneProperties.call( this, geometry ); THREE.BufferGeometry.prototype._copyFrom.call( geometry, this );
return geometry; return geometry;
......
...@@ -243,13 +243,13 @@ THREE.PolyhedronGeometry.prototype.clone = function () { ...@@ -243,13 +243,13 @@ THREE.PolyhedronGeometry.prototype.clone = function () {
this.parameters.detail this.parameters.detail
); );
return this.cloneProperties( geometry ); return geometry._copyFrom( this );
}; };
THREE.PolyhedronGeometry.prototype.cloneProperties = function ( geometry ) { THREE.PolyhedronGeometry.prototype._copyFrom = function ( source ) {
THREE.Geometry.prototype.cloneProperties.call( this, geometry ); THREE.Geometry.prototype._copyFrom.call( this, source );
return geometry; return this;
}; };
...@@ -112,7 +112,7 @@ THREE.SphereBufferGeometry.prototype.clone = function () { ...@@ -112,7 +112,7 @@ THREE.SphereBufferGeometry.prototype.clone = function () {
this.parameters.thetaLength this.parameters.thetaLength
); );
THREE.BufferGeometry.prototype.cloneProperties.call( this, geometry ); THREE.BufferGeometry.prototype._copyFrom.call( geometry, this );
return geometry; return geometry;
......
...@@ -33,7 +33,7 @@ THREE.TetrahedronGeometry.prototype.clone = function () { ...@@ -33,7 +33,7 @@ THREE.TetrahedronGeometry.prototype.clone = function () {
this.parameters.detail this.parameters.detail
); );
THREE.PolyhedronGeometry.prototype.cloneProperties.call( this, geometry ); THREE.PolyhedronGeometry.prototype._copyFrom.call( geometry, this );
return geometry; return geometry;
......
...@@ -17,7 +17,7 @@ THREE.AmbientLight.prototype.clone = function () { ...@@ -17,7 +17,7 @@ THREE.AmbientLight.prototype.clone = function () {
var light = new THREE.AmbientLight(); var light = new THREE.AmbientLight();
THREE.Light.prototype.cloneProperties.call( this, light ); THREE.Light.prototype._copyFrom.call( light, this );
return light; return light;
......
...@@ -31,7 +31,7 @@ THREE.AreaLight.prototype.clone = function () { ...@@ -31,7 +31,7 @@ THREE.AreaLight.prototype.clone = function () {
var light = new THREE.AreaLight(); var light = new THREE.AreaLight();
THREE.Light.prototype.cloneProperties.call( this, light ); THREE.Light.prototype._copyFrom.call( light, this );
light.normal.copy(this.normal); light.normal.copy(this.normal);
light.right.copy(this.right); light.right.copy(this.right);
...@@ -40,7 +40,7 @@ THREE.AreaLight.prototype.clone = function () { ...@@ -40,7 +40,7 @@ THREE.AreaLight.prototype.clone = function () {
light.height = this.height; light.height = this.height;
light.constantAttenuation = this.constantAttenuation; light.constantAttenuation = this.constantAttenuation;
light.linearAttenuation = this.linearAttenuation; light.linearAttenuation = this.linearAttenuation;
light.quadraticAttenuation = this.quadraticAttenuation light.quadraticAttenuation = this.quadraticAttenuation;
return light; return light;
......
...@@ -67,7 +67,7 @@ THREE.DirectionalLight.prototype.clone = function () { ...@@ -67,7 +67,7 @@ THREE.DirectionalLight.prototype.clone = function () {
var light = new THREE.DirectionalLight(); var light = new THREE.DirectionalLight();
THREE.Light.prototype.cloneProperties.call( this, light ); THREE.Light.prototype._copyFrom.call( light, this );
light.target = this.target.clone(); light.target = this.target.clone();
......
...@@ -22,7 +22,7 @@ THREE.HemisphereLight.prototype.clone = function () { ...@@ -22,7 +22,7 @@ THREE.HemisphereLight.prototype.clone = function () {
var light = new THREE.HemisphereLight(); var light = new THREE.HemisphereLight();
THREE.Light.prototype.cloneProperties.call( this, light ); THREE.Light.prototype._copyFrom.call( light, this );
light.groundColor.copy( this.groundColor ); light.groundColor.copy( this.groundColor );
light.intensity = this.intensity; light.intensity = this.intensity;
......
...@@ -19,15 +19,15 @@ THREE.Light.prototype.constructor = THREE.Light; ...@@ -19,15 +19,15 @@ THREE.Light.prototype.constructor = THREE.Light;
THREE.Light.prototype.clone = function () { THREE.Light.prototype.clone = function () {
var light = new THREE.Light(); var light = new THREE.Light();
return this.cloneProperties( light ); return light._copyFrom( this );
}; };
THREE.Light.prototype.cloneProperties = function ( light ) { THREE.Light.prototype._copyFrom = function ( source ) {
THREE.Object3D.prototype.cloneProperties.call( this, light ); THREE.Object3D.prototype._copyFrom.call( this, source );
light.color.copy( this.color ); this.color.copy( source.color );
return light; return this;
}; };
...@@ -21,7 +21,7 @@ THREE.PointLight.prototype.clone = function () { ...@@ -21,7 +21,7 @@ THREE.PointLight.prototype.clone = function () {
var light = new THREE.PointLight(); var light = new THREE.PointLight();
THREE.Light.prototype.cloneProperties.call( this, light ); THREE.Light.prototype._copyFrom.call( light, this );
light.intensity = this.intensity; light.intensity = this.intensity;
light.distance = this.distance; light.distance = this.distance;
......
...@@ -50,7 +50,7 @@ THREE.SpotLight.prototype.clone = function () { ...@@ -50,7 +50,7 @@ THREE.SpotLight.prototype.clone = function () {
var light = new THREE.SpotLight(); var light = new THREE.SpotLight();
THREE.Light.prototype.cloneProperties.call( this, light ); THREE.Light.prototype._copyFrom.call( light, this );
light.target = this.target.clone(); light.target = this.target.clone();
......
...@@ -47,7 +47,7 @@ THREE.LineBasicMaterial.prototype.clone = function () { ...@@ -47,7 +47,7 @@ THREE.LineBasicMaterial.prototype.clone = function () {
var material = new THREE.LineBasicMaterial(); var material = new THREE.LineBasicMaterial();
THREE.Material.prototype.cloneProperties.call( this, material ); THREE.Material.prototype._copyFrom.call( material, this );
material.color.copy( this.color ); material.color.copy( this.color );
......
...@@ -50,7 +50,7 @@ THREE.LineDashedMaterial.prototype.clone = function () { ...@@ -50,7 +50,7 @@ THREE.LineDashedMaterial.prototype.clone = function () {
var material = new THREE.LineDashedMaterial(); var material = new THREE.LineDashedMaterial();
THREE.Material.prototype.cloneProperties.call( this, material ); THREE.Material.prototype._copyFrom.call( material, this );
material.color.copy( this.color ); material.color.copy( this.color );
......
...@@ -164,43 +164,43 @@ THREE.Material.prototype = { ...@@ -164,43 +164,43 @@ THREE.Material.prototype = {
clone: function () { clone: function () {
var material = new THREE.Material(); var material = new THREE.Material();
return this.cloneProperties( material ); return material._copyFrom( this );
}, },
cloneProperties: function ( material ) { _copyFrom: function ( source ) {
material.name = this.name; this.name = source.name;
material.side = this.side; this.side = source.side;
material.opacity = this.opacity; this.opacity = source.opacity;
material.transparent = this.transparent; this.transparent = source.transparent;
material.blending = this.blending; this.blending = source.blending;
material.blendSrc = this.blendSrc; this.blendSrc = source.blendSrc;
material.blendDst = this.blendDst; this.blendDst = source.blendDst;
material.blendEquation = this.blendEquation; this.blendEquation = source.blendEquation;
material.blendSrcAlpha = this.blendSrcAlpha; this.blendSrcAlpha = source.blendSrcAlpha;
material.blendDstAlpha = this.blendDstAlpha; this.blendDstAlpha = source.blendDstAlpha;
material.blendEquationAlpha = this.blendEquationAlpha; this.blendEquationAlpha = source.blendEquationAlpha;
material.depthFunc = this.depthFunc; this.depthFunc = source.depthFunc;
material.depthTest = this.depthTest; this.depthTest = source.depthTest;
material.depthWrite = this.depthWrite; this.depthWrite = source.depthWrite;
material.polygonOffset = this.polygonOffset; this.polygonOffset = source.polygonOffset;
material.polygonOffsetFactor = this.polygonOffsetFactor; this.polygonOffsetFactor = source.polygonOffsetFactor;
material.polygonOffsetUnits = this.polygonOffsetUnits; this.polygonOffsetUnits = source.polygonOffsetUnits;
material.alphaTest = this.alphaTest; this.alphaTest = source.alphaTest;
material.overdraw = this.overdraw; this.overdraw = source.overdraw;
material.visible = this.visible; this.visible = source.visible;
return material; return this;
}, },
......
...@@ -83,7 +83,7 @@ THREE.MeshBasicMaterial.prototype.clone = function () { ...@@ -83,7 +83,7 @@ THREE.MeshBasicMaterial.prototype.clone = function () {
var material = new THREE.MeshBasicMaterial(); var material = new THREE.MeshBasicMaterial();
THREE.Material.prototype.cloneProperties.call( this, material ); THREE.Material.prototype._copyFrom.call( material, this );
material.color.copy( this.color ); material.color.copy( this.color );
......
...@@ -35,7 +35,7 @@ THREE.MeshDepthMaterial.prototype.clone = function () { ...@@ -35,7 +35,7 @@ THREE.MeshDepthMaterial.prototype.clone = function () {
var material = new THREE.MeshDepthMaterial(); var material = new THREE.MeshDepthMaterial();
THREE.Material.prototype.cloneProperties.call( this, material ); THREE.Material.prototype._copyFrom.call( material, this );
material.wireframe = this.wireframe; material.wireframe = this.wireframe;
material.wireframeLinewidth = this.wireframeLinewidth; material.wireframeLinewidth = this.wireframeLinewidth;
......
...@@ -82,7 +82,7 @@ THREE.MeshLambertMaterial.prototype.clone = function () { ...@@ -82,7 +82,7 @@ THREE.MeshLambertMaterial.prototype.clone = function () {
var material = new THREE.MeshLambertMaterial(); var material = new THREE.MeshLambertMaterial();
THREE.Material.prototype.cloneProperties.call( this, material ); THREE.Material.prototype._copyFrom.call( material, this );
material.color.copy( this.color ); material.color.copy( this.color );
material.emissive.copy( this.emissive ); material.emissive.copy( this.emissive );
......
...@@ -36,7 +36,7 @@ THREE.MeshNormalMaterial.prototype.clone = function () { ...@@ -36,7 +36,7 @@ THREE.MeshNormalMaterial.prototype.clone = function () {
var material = new THREE.MeshNormalMaterial(); var material = new THREE.MeshNormalMaterial();
THREE.Material.prototype.cloneProperties.call( this, material ); THREE.Material.prototype._copyFrom.call( material, this );
material.wireframe = this.wireframe; material.wireframe = this.wireframe;
material.wireframeLinewidth = this.wireframeLinewidth; material.wireframeLinewidth = this.wireframeLinewidth;
......
...@@ -116,7 +116,7 @@ THREE.MeshPhongMaterial.prototype.clone = function () { ...@@ -116,7 +116,7 @@ THREE.MeshPhongMaterial.prototype.clone = function () {
var material = new THREE.MeshPhongMaterial(); var material = new THREE.MeshPhongMaterial();
THREE.Material.prototype.cloneProperties.call( this, material ); THREE.Material.prototype._copyFrom.call( material, this );
material.color.copy( this.color ); material.color.copy( this.color );
material.emissive.copy( this.emissive ); material.emissive.copy( this.emissive );
......
...@@ -48,7 +48,7 @@ THREE.PointCloudMaterial.prototype.clone = function () { ...@@ -48,7 +48,7 @@ THREE.PointCloudMaterial.prototype.clone = function () {
var material = new THREE.PointCloudMaterial(); var material = new THREE.PointCloudMaterial();
THREE.Material.prototype.cloneProperties.call( this, material ); THREE.Material.prototype._copyFrom.call( material, this );
material.color.copy( this.color ); material.color.copy( this.color );
......
...@@ -17,7 +17,7 @@ THREE.RawShaderMaterial.prototype.clone = function () { ...@@ -17,7 +17,7 @@ THREE.RawShaderMaterial.prototype.clone = function () {
var material = new THREE.RawShaderMaterial(); var material = new THREE.RawShaderMaterial();
THREE.ShaderMaterial.prototype.cloneProperties.call( this, material ); THREE.ShaderMaterial.prototype._copyFrom.call( material, this );
return material; return material;
......
...@@ -92,39 +92,39 @@ THREE.ShaderMaterial.prototype.constructor = THREE.ShaderMaterial; ...@@ -92,39 +92,39 @@ THREE.ShaderMaterial.prototype.constructor = THREE.ShaderMaterial;
THREE.ShaderMaterial.prototype.clone = function () { THREE.ShaderMaterial.prototype.clone = function () {
var material = new THREE.ShaderMaterial(); var material = new THREE.ShaderMaterial();
return this.clone( material ); return material._copyFrom( this );
}; };
THREE.ShaderMaterial.prototype.cloneProperties = function ( material ) { THREE.ShaderMaterial.prototype._copyFrom = function ( source ) {
THREE.Material.prototype.cloneProperties.call( this, material ); THREE.Material.prototype._copyFrom.call( this, source );
material.fragmentShader = this.fragmentShader; this.fragmentShader = source.fragmentShader;
material.vertexShader = this.vertexShader; this.vertexShader = source.vertexShader;
material.uniforms = THREE.UniformsUtils.clone( this.uniforms ); this.uniforms = THREE.UniformsUtils.clone( source.uniforms );
material.attributes = this.attributes; this.attributes = source.attributes;
material.defines = this.defines; this.defines = source.defines;
material.shading = this.shading; this.shading = source.shading;
material.wireframe = this.wireframe; this.wireframe = source.wireframe;
material.wireframeLinewidth = this.wireframeLinewidth; this.wireframeLinewidth = source.wireframeLinewidth;
material.fog = this.fog; this.fog = source.fog;
material.lights = this.lights; this.lights = source.lights;
material.vertexColors = this.vertexColors; this.vertexColors = source.vertexColors;
material.skinning = this.skinning; this.skinning = source.skinning;
material.morphTargets = this.morphTargets; this.morphTargets = source.morphTargets;
material.morphNormals = this.morphNormals; this.morphNormals = source.morphNormals;
return material; return this;
}; };
......
...@@ -43,7 +43,7 @@ THREE.SpriteMaterial.prototype.clone = function () { ...@@ -43,7 +43,7 @@ THREE.SpriteMaterial.prototype.clone = function () {
var material = new THREE.SpriteMaterial(); var material = new THREE.SpriteMaterial();
THREE.Material.prototype.cloneProperties.call( this, material ); THREE.Material.prototype._copyFrom.call( material, this );
material.color.copy( this.color ); material.color.copy( this.color );
material.map = this.map; material.map = this.map;
......
...@@ -20,15 +20,15 @@ THREE.Bone.prototype.constructor = THREE.Bone; ...@@ -20,15 +20,15 @@ THREE.Bone.prototype.constructor = THREE.Bone;
THREE.Bone.prototype.clone = function () { THREE.Bone.prototype.clone = function () {
var bone = new THREE.Bone( this.skin ); var bone = new THREE.Bone( this.skin );
return this.cloneProperties( bone ); return bone._copyFrom( this );
}; };
THREE.Bone.prototype.cloneProperties = function ( bone ) { THREE.Bone.prototype._copyFrom = function ( source ) {
THREE.Object3D.prototype.cloneProperties.call( this, bone ); THREE.Object3D.prototype._copyFrom.call( this, source );
bone.skin = this.skin; this.skin = source.skin;
return bone; return this;
}; };
...@@ -16,13 +16,13 @@ THREE.Group.prototype.constructor = THREE.Group; ...@@ -16,13 +16,13 @@ THREE.Group.prototype.constructor = THREE.Group;
THREE.Group.prototype.clone = function () { THREE.Group.prototype.clone = function () {
var group = new THREE.Group(); var group = new THREE.Group();
return this.cloneProperties( group ); return group._copyFrom( this );
}; };
THREE.Group.prototype.cloneProperties = function ( group ) { THREE.Group.prototype._copyFrom = function ( source ) {
THREE.Object3D.prototype.cloneProperties.call( this, group ); THREE.Object3D.prototype._copyFrom.call( this, source );
return group; return this;
}; };
...@@ -133,25 +133,25 @@ THREE.LOD.prototype.update = function () { ...@@ -133,25 +133,25 @@ THREE.LOD.prototype.update = function () {
THREE.LOD.prototype.clone = function () { THREE.LOD.prototype.clone = function () {
var lod = new THREE.LOD(); var lod = new THREE.LOD();
return this.cloneProperties( lod ); return lod._copyFrom( this );
}; };
THREE.LOD.prototype.cloneProperties = function ( lod ) { THREE.LOD.prototype._copyFrom = function ( source ) {
THREE.Object3D.prototype.cloneProperties.call( this, lod, false ); THREE.Object3D.prototype._copyFrom.call( this, source, false );
var levels = this.levels; var levels = source.levels;
for ( var i = 0, l = levels.length; i < l; i ++ ) { for ( var i = 0, l = levels.length; i < l; i ++ ) {
var level = levels[ i ]; var level = levels[ i ];
lod.addLevel( level.object.clone(), level.distance ); this.addLevel( level.object.clone(), level.distance );
} }
return lod; return this;
}; };
...@@ -81,23 +81,23 @@ THREE.LensFlare.prototype.updateLensFlares = function () { ...@@ -81,23 +81,23 @@ THREE.LensFlare.prototype.updateLensFlares = function () {
THREE.LensFlare.prototype.clone = function () { THREE.LensFlare.prototype.clone = function () {
var flare = new THREE.LensFlare(); var flare = new THREE.LensFlare();
return this.cloneProperties( flare ); return flare._copyFrom( this );
}; };
THREE.LensFlare.prototype.cloneProperties = function ( flare ) { THREE.LensFlare.prototype._copyFrom = function ( source ) {
THREE.Object3D.prototype.cloneProperties.call( this, flare ); THREE.Object3D.prototype._copyFrom.call( this, source );
flare.positionScreen.copy( this.positionScreen ); this.positionScreen.copy( source.positionScreen );
flare.customUpdateCallback = this.customUpdateCallback; this.customUpdateCallback = source.customUpdateCallback;
for ( var i = 0, l = this.lensFlares.length; i < l; i ++ ) { for ( var i = 0, l = source.lensFlares.length; i < l; i ++ ) {
flare.lensFlares.push( this.lensFlares[ i ] ); this.lensFlares.push( source.lensFlares[ i ] );
} }
return flare; return this;
}; };
...@@ -186,14 +186,14 @@ THREE.Line.prototype.raycast = ( function () { ...@@ -186,14 +186,14 @@ THREE.Line.prototype.raycast = ( function () {
THREE.Line.prototype.clone = function () { THREE.Line.prototype.clone = function () {
var line = new THREE.Line( this.geometry, this.material ); var line = new THREE.Line( this.geometry, this.material );
return this.cloneProperties( line ); return line._copyFrom( this );
}; };
THREE.Line.prototype.cloneProperties = function ( line ) { THREE.Line.prototype._copyFrom = function ( source ) {
THREE.Object3D.prototype.cloneProperties.call( this, line ); THREE.Object3D.prototype._copyFrom.call( this, source );
return line; return this;
}; };
......
...@@ -17,7 +17,7 @@ THREE.LineSegments.prototype.clone = function () { ...@@ -17,7 +17,7 @@ THREE.LineSegments.prototype.clone = function () {
var line = new THREE.LineSegments( this.geometry, this.material ); var line = new THREE.LineSegments( this.geometry, this.material );
THREE.Line.prototype.cloneProperties.call( this, line ); THREE.Line.prototype._copyFrom.call( line, this );
return line; return line;
......
...@@ -308,15 +308,14 @@ THREE.Mesh.prototype.raycast = ( function () { ...@@ -308,15 +308,14 @@ THREE.Mesh.prototype.raycast = ( function () {
THREE.Mesh.prototype.clone = function () { THREE.Mesh.prototype.clone = function () {
var mesh = new THREE.Mesh( this.geometry, this.material ); var mesh = new THREE.Mesh( this.geometry, this.material );
return this.cloneProperties( mesh ); return mesh._copyFrom( this );
}; };
THREE.Mesh.prototype.cloneProperties = function ( mesh ) { THREE.Mesh.prototype._copyFrom = function ( source ) {
THREE.Object3D.prototype.cloneProperties.call( this, mesh ); THREE.Object3D.prototype._copyFrom.call( this, source );
return this;
return mesh;
}; };
......
...@@ -195,24 +195,24 @@ THREE.MorphAnimMesh.prototype.interpolateTargets = function ( a, b, t ) { ...@@ -195,24 +195,24 @@ THREE.MorphAnimMesh.prototype.interpolateTargets = function ( a, b, t ) {
THREE.MorphAnimMesh.prototype.clone = function () { THREE.MorphAnimMesh.prototype.clone = function () {
var morph = new THREE.MorphAnimMesh( this.geometry, this.material ); var morph = new THREE.MorphAnimMesh( this.geometry, this.material );
return this.cloneProperties( morph ); return morph._copyFrom( this );
}; };
THREE.MorphAnimMesh.prototype.cloneProperties = function ( morph ) { THREE.MorphAnimMesh.prototype._copyFrom = function ( source ) {
morph.duration = this.duration; this.duration = source.duration;
morph.mirroredLoop = this.mirroredLoop; this.mirroredLoop = source.mirroredLoop;
morph.time = this.time; this.time = source.time;
morph.lastKeyframe = this.lastKeyframe; this.lastKeyframe = source.lastKeyframe;
morph.currentKeyframe = this.currentKeyframe; this.currentKeyframe = source.currentKeyframe;
morph.direction = this.direction; this.direction = source.direction;
morph.directionBackwards = this.directionBackwards; this.directionBackwards = source.directionBackwards;
THREE.Mesh.prototype.cloneProperties.call( this, morph ); THREE.Mesh.prototype._copyFrom.call( this, source );
return morph; return this;
}; };
...@@ -139,14 +139,14 @@ THREE.PointCloud.prototype.raycast = ( function () { ...@@ -139,14 +139,14 @@ THREE.PointCloud.prototype.raycast = ( function () {
THREE.PointCloud.prototype.clone = function () { THREE.PointCloud.prototype.clone = function () {
var pointCloud = new THREE.PointCloud( this.geometry, this.material ); var pointCloud = new THREE.PointCloud( this.geometry, this.material );
return this.cloneProperties( pointCloud ); return pointCloud._copyFrom( this );
}; };
THREE.PointCloud.prototype.cloneProperties = function ( pointCloud ) { THREE.PointCloud.prototype._copyFrom = function ( source ) {
THREE.Object3D.prototype.cloneProperties.call( this, pointCloud ); THREE.Object3D.prototype._copyFrom.call( this, source );
return pointCloud; return this;
}; };
......
...@@ -157,13 +157,13 @@ THREE.SkinnedMesh.prototype.updateMatrixWorld = function( force ) { ...@@ -157,13 +157,13 @@ THREE.SkinnedMesh.prototype.updateMatrixWorld = function( force ) {
THREE.SkinnedMesh.prototype.clone = function() { THREE.SkinnedMesh.prototype.clone = function() {
var skinMesh = new THREE.SkinnedMesh( this.geometry, this.material, this.useVertexTexture ); var skinMesh = new THREE.SkinnedMesh( this.geometry, this.material, this.useVertexTexture );
return this.cloneProperties( skinMesh ); return skinMesh._copyFrom( this );
}; };
THREE.SkinnedMesh.prototype.cloneProperties = function( skinMesh ) { THREE.SkinnedMesh.prototype._copyFrom = function( source ) {
THREE.Mesh.prototype.cloneProperties.call( this, skinMesh ); THREE.Mesh.prototype._copyFrom.call( this, source );
return skinMesh; return this;
}; };
...@@ -63,14 +63,14 @@ THREE.Sprite.prototype.raycast = ( function () { ...@@ -63,14 +63,14 @@ THREE.Sprite.prototype.raycast = ( function () {
THREE.Sprite.prototype.clone = function () { THREE.Sprite.prototype.clone = function () {
var sprite = new THREE.Sprite( this.material ); var sprite = new THREE.Sprite( this.material );
return this.cloneProperties( sprite ); return sprite._copyFrom( this );
}; };
THREE.Sprite.prototype.cloneProperties = function ( sprite ) { THREE.Sprite.prototype._copyFrom = function ( source ) {
THREE.Object3D.prototype.cloneProperties.call( this, sprite ); THREE.Object3D.prototype._copyFrom.call( this, source );
return sprite; return this;
}; };
......
...@@ -21,22 +21,20 @@ THREE.Scene.prototype.constructor = THREE.Scene; ...@@ -21,22 +21,20 @@ THREE.Scene.prototype.constructor = THREE.Scene;
THREE.Scene.prototype.clone = function () { THREE.Scene.prototype.clone = function () {
var scene = new THREE.Scene(); var scene = new THREE.Scene();
return this.cloneProperties( scene ); return scene._copyFrom( this );
}; };
THREE.Scene.prototype.cloneProperties = function ( scene ) { THREE.Scene.prototype._copyFrom = function ( source ) {
if ( scene === undefined ) scene = new THREE.Scene(); THREE.Object3D.prototype._copyFrom.call( this, source );
THREE.Object3D.prototype.cloneProperties.call( this, scene ); if ( source.fog !== null ) this.fog = source.fog.clone();
if ( source.overrideMaterial !== null ) this.overrideMaterial = source.overrideMaterial.clone();
if ( this.fog !== null ) scene.fog = this.fog.clone(); this.autoUpdate = source.autoUpdate;
if ( this.overrideMaterial !== null ) scene.overrideMaterial = this.overrideMaterial.clone(); this.matrixAutoUpdate = source.matrixAutoUpdate;
scene.autoUpdate = this.autoUpdate; return this;
scene.matrixAutoUpdate = this.matrixAutoUpdate;
return scene;
}; };
...@@ -28,7 +28,7 @@ THREE.CompressedTexture.prototype.clone = function () { ...@@ -28,7 +28,7 @@ THREE.CompressedTexture.prototype.clone = function () {
var texture = new THREE.CompressedTexture(); var texture = new THREE.CompressedTexture();
THREE.Texture.prototype.cloneProperties.call( this, texture ); THREE.Texture.prototype._copyFrom.call( texture, this );
return texture; return texture;
......
...@@ -20,7 +20,7 @@ THREE.CubeTexture.clone = function () { ...@@ -20,7 +20,7 @@ THREE.CubeTexture.clone = function () {
var texture = new THREE.CubeTexture(); var texture = new THREE.CubeTexture();
THREE.Texture.prototype.cloneProperties.call( this, texture ); THREE.Texture.prototype._copyFrom.call( texture, this );
texture.images = this.images; texture.images = this.images;
......
...@@ -17,7 +17,7 @@ THREE.DataTexture.prototype.clone = function () { ...@@ -17,7 +17,7 @@ THREE.DataTexture.prototype.clone = function () {
var texture = new THREE.DataTexture(); var texture = new THREE.DataTexture();
THREE.Texture.prototype.cloneProperties.call( this, texture ); THREE.Texture.prototype._copyFrom.call( texture, this );
return texture; return texture;
......
...@@ -66,37 +66,37 @@ THREE.Texture.prototype = { ...@@ -66,37 +66,37 @@ THREE.Texture.prototype = {
clone: function () { clone: function () {
var texture = new THREE.Texture(); var texture = new THREE.Texture();
return this.cloneProperties( texture ); return texture._copyFrom( this );
}, },
cloneProperties: function ( texture ) { _copyFrom: function ( source ) {
texture.image = this.image; this.image = source.image;
texture.mipmaps = this.mipmaps.slice( 0 ); this.mipmaps = source.mipmaps.slice( 0 );
texture.mapping = this.mapping; this.mapping = source.mapping;
texture.wrapS = this.wrapS; this.wrapS = source.wrapS;
texture.wrapT = this.wrapT; this.wrapT = source.wrapT;
texture.magFilter = this.magFilter; this.magFilter = source.magFilter;
texture.minFilter = this.minFilter; this.minFilter = source.minFilter;
texture.anisotropy = this.anisotropy; this.anisotropy = source.anisotropy;
texture.format = this.format; this.format = source.format;
texture.type = this.type; this.type = source.type;
texture.offset.copy( this.offset ); this.offset.copy( source.offset );
texture.repeat.copy( this.repeat ); this.repeat.copy( source.repeat );
texture.generateMipmaps = this.generateMipmaps; this.generateMipmaps = source.generateMipmaps;
texture.premultiplyAlpha = this.premultiplyAlpha; this.premultiplyAlpha = source.premultiplyAlpha;
texture.flipY = this.flipY; this.flipY = source.flipY;
texture.unpackAlignment = this.unpackAlignment; this.unpackAlignment = source.unpackAlignment;
return texture; return this;
}, },
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册