提交 8d3f1ce6 编写于 作者: D Daniel Hritzkiv

Prefer one-line constructor+copy in clone methods

上级 9a9d73d4
......@@ -52,8 +52,7 @@ THREE.Camera.prototype.lookAt = function () {
THREE.Camera.prototype.clone = function () {
var camera = new this.constructor();
return camera.copy( this );
return new this.constructor().copy( this );
};
......
......@@ -1241,8 +1241,7 @@ THREE.BufferGeometry.prototype = {
clone: function () {
var bufferGeometry = new this.constructor();
return bufferGeometry.copy( this );
return new this.constructor().copy( this );
},
......
......@@ -27,8 +27,7 @@ THREE.Face3.prototype = {
clone: function () {
var face = new this.constructor();
return face.copy( this );
return new this.constructor().copy( this );
},
......
......@@ -1174,8 +1174,7 @@ THREE.Geometry.prototype = {
clone: function () {
var geometry = new this.constructor();
return geometry.copy( this );
return new this.constructor().copy( this );
},
......
......@@ -675,8 +675,7 @@ THREE.Object3D.prototype = {
clone: function ( recursive ) {
var object = new this.constructor();
return object.copy( this, recursive );
return new this.constructor().copy( this, recursive );
},
......
......@@ -172,8 +172,7 @@ THREE.Material.prototype = {
clone: function () {
var material = new this.constructor();
return material.copy( this );
return new this.constructor().copy( this );
},
......
......@@ -54,8 +54,7 @@ THREE.Box2.prototype = {
clone: function () {
var box = new this.constructor();
return box.copy( this );
return new this.constructor().copy( this );
},
......
......@@ -117,8 +117,7 @@ THREE.Box3.prototype = {
clone: function () {
var box = new this.constructor();
return box.copy( this );
return new this.constructor().copy( this );
},
......
......@@ -40,8 +40,7 @@ THREE.Frustum.prototype = {
clone: function () {
var frustum = new this.constructor();
return frustum.copy( this );
return new this.constructor().copy( this );
},
......
......@@ -24,8 +24,7 @@ THREE.Line3.prototype = {
clone: function () {
var line = new this.constructor();
return line.copy( this );
return new this.constructor().copy( this );
},
......
......@@ -54,8 +54,7 @@ THREE.Matrix3.prototype = {
clone: function () {
var matrix = new this.constructor();
return matrix.fromArray( this.elements );
return new this.constructor().fromArray( this.elements );
},
......
......@@ -61,8 +61,7 @@ THREE.Plane.prototype = {
clone: function () {
var plane = new this.constructor();
return plane.copy( this );
return new this.constructor().copy( this );
},
......
......@@ -24,8 +24,7 @@ THREE.Ray.prototype = {
clone: function () {
var ray = new this.constructor();
return ray.copy( this );
return new this.constructor().copy( this );
},
......
......@@ -59,8 +59,7 @@ THREE.Sphere.prototype = {
clone: function () {
var sphere = new this.constructor();
return sphere.copy( this );
return new this.constructor().copy( this );
},
......
......@@ -120,8 +120,7 @@ THREE.Triangle.prototype = {
clone: function () {
var triangle = new this.constructor();
return triangle.copy( this );
return new this.constructor().copy( this );
},
......
......@@ -185,8 +185,7 @@ THREE.Line.prototype.raycast = ( function () {
THREE.Line.prototype.clone = function () {
var line = new this.constructor( this.geometry, this.material );
return line.copy( this );
return new this.constructor( this.geometry, this.material ).copy( this );
};
......
......@@ -307,8 +307,7 @@ THREE.Mesh.prototype.raycast = ( function () {
THREE.Mesh.prototype.clone = function () {
var mesh = new this.constructor( this.geometry, this.material );
return mesh.copy( this );
return new this.constructor( this.geometry, this.material ).copy( this );
};
......
......@@ -138,8 +138,7 @@ THREE.PointCloud.prototype.raycast = ( function () {
THREE.PointCloud.prototype.clone = function () {
var pointCloud = new this.constructor( this.geometry, this.material );
return pointCloud.copy( this );
return new this.constructor( this.geometry, this.material ).copy( this );
};
......
......@@ -145,7 +145,6 @@ THREE.SkinnedMesh.prototype.updateMatrixWorld = function( force ) {
THREE.SkinnedMesh.prototype.clone = function() {
var skinMesh = new this.constructor( this.geometry, this.material, this.useVertexTexture );
return skinMesh.copy( this );
return new this.constructor( this.geometry, this.material, this.useVertexTexture ).copy( this );
};
......@@ -62,8 +62,7 @@ THREE.Sprite.prototype.raycast = ( function () {
THREE.Sprite.prototype.clone = function () {
var sprite = new this.constructor( this.material );
return sprite.copy( this );
return new this.constructor( this.material ).copy( this );
};
......
......@@ -54,8 +54,7 @@ THREE.WebGLRenderTarget.prototype = {
clone: function () {
var renderTarget = new this.constructor();
return renderTarget.copy( this );
return new this.constructor().copy( this );
},
......
......@@ -57,8 +57,7 @@ THREE.Texture.prototype = {
clone: function () {
var texture = new this.constructor();
return texture.copy( this );
return new this.constructor().copy( this );
},
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册