|
@@ -20,7 +20,7 @@ import { _Math } from '../math/Math';
|
|
|
*/
|
|
|
|
|
|
var count = 0;
|
|
|
-function GeometryIdCount() { return count++; };
|
|
|
+function GeometryIdCount() { return count++; }
|
|
|
|
|
|
function Geometry() {
|
|
|
|
|
@@ -1200,36 +1200,59 @@ Geometry.prototype = {
|
|
|
|
|
|
copy: function ( source ) {
|
|
|
|
|
|
+ var i, il, j, jl, k, kl;
|
|
|
+
|
|
|
+ // reset
|
|
|
+
|
|
|
this.vertices = [];
|
|
|
- this.faces = [];
|
|
|
- this.faceVertexUvs = [ [] ];
|
|
|
this.colors = [];
|
|
|
+ this.faces = [];
|
|
|
+ this.faceVertexUvs = [[]];
|
|
|
+ this.morphTargets = [];
|
|
|
+ this.morphNormals = [];
|
|
|
+ this.skinWeights = [];
|
|
|
+ this.skinIndices = [];
|
|
|
+ this.lineDistances = [];
|
|
|
+ this.boundingBox = null;
|
|
|
+ this.boundingSphere = null;
|
|
|
+
|
|
|
+ // name
|
|
|
+
|
|
|
+ this.name = source.name;
|
|
|
+
|
|
|
+ // vertices
|
|
|
|
|
|
var vertices = source.vertices;
|
|
|
|
|
|
- for ( var i = 0, il = vertices.length; i < il; i ++ ) {
|
|
|
+ for ( i = 0, il = vertices.length; i < il; i ++ ) {
|
|
|
|
|
|
this.vertices.push( vertices[ i ].clone() );
|
|
|
|
|
|
}
|
|
|
|
|
|
+ // colors
|
|
|
+
|
|
|
var colors = source.colors;
|
|
|
|
|
|
- for ( var i = 0, il = colors.length; i < il; i ++ ) {
|
|
|
+ for ( i = 0, il = colors.length; i < il; i ++ ) {
|
|
|
|
|
|
this.colors.push( colors[ i ].clone() );
|
|
|
|
|
|
}
|
|
|
|
|
|
+ // faces
|
|
|
+
|
|
|
var faces = source.faces;
|
|
|
|
|
|
- for ( var i = 0, il = faces.length; i < il; i ++ ) {
|
|
|
+ for ( i = 0, il = faces.length; i < il; i ++ ) {
|
|
|
|
|
|
this.faces.push( faces[ i ].clone() );
|
|
|
|
|
|
}
|
|
|
|
|
|
- for ( var i = 0, il = source.faceVertexUvs.length; i < il; i ++ ) {
|
|
|
+ // face vertex uvs
|
|
|
+
|
|
|
+ for ( i = 0, il = source.faceVertexUvs.length; i < il; i ++ ) {
|
|
|
|
|
|
var faceVertexUvs = source.faceVertexUvs[ i ];
|
|
|
|
|
@@ -1239,11 +1262,11 @@ Geometry.prototype = {
|
|
|
|
|
|
}
|
|
|
|
|
|
- for ( var j = 0, jl = faceVertexUvs.length; j < jl; j ++ ) {
|
|
|
+ for ( j = 0, jl = faceVertexUvs.length; j < jl; j ++ ) {
|
|
|
|
|
|
var uvs = faceVertexUvs[ j ], uvsCopy = [];
|
|
|
|
|
|
- for ( var k = 0, kl = uvs.length; k < kl; k ++ ) {
|
|
|
+ for ( k = 0, kl = uvs.length; k < kl; k ++ ) {
|
|
|
|
|
|
var uv = uvs[ k ];
|
|
|
|
|
@@ -1257,6 +1280,154 @@ Geometry.prototype = {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ // morph targets
|
|
|
+
|
|
|
+ var morphTargets = source.morphTargets;
|
|
|
+
|
|
|
+ for ( i = 0, il = morphTargets.length; i < il; i ++ ) {
|
|
|
+
|
|
|
+ var morphTarget = {};
|
|
|
+ morphTarget.name = morphTargets[ i ].name;
|
|
|
+
|
|
|
+ // vertices
|
|
|
+
|
|
|
+ if ( morphTargets[ i ].vertices !== undefined ) {
|
|
|
+
|
|
|
+ morphTarget.vertices = [];
|
|
|
+
|
|
|
+ for ( j = 0, jl = morphTargets[ i ].vertices.length; j < jl; j ++ ) {
|
|
|
+
|
|
|
+ morphTarget.vertices.push( morphTargets[ i ].vertices[ j ].clone() );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ // normals
|
|
|
+
|
|
|
+ if ( morphTargets[ i ].normals !== undefined ) {
|
|
|
+
|
|
|
+ morphTarget.normals = [];
|
|
|
+
|
|
|
+ for ( j = 0, jl = morphTargets[ i ].normals.length; j < jl; j ++ ) {
|
|
|
+
|
|
|
+ morphTarget.normals.push( morphTargets[ i ].normals[ j ].clone() );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ this.morphTargets.push( morphTarget );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ // morph normals
|
|
|
+
|
|
|
+ var morphNormals = source.morphNormals;
|
|
|
+
|
|
|
+ for ( i = 0, il = morphNormals.length; i < il; i ++ ) {
|
|
|
+
|
|
|
+ var morphNormal = {};
|
|
|
+
|
|
|
+ // vertex normals
|
|
|
+
|
|
|
+ if ( morphNormals[ i ].vertexNormals !== undefined ) {
|
|
|
+
|
|
|
+ morphNormal.vertexNormals = [];
|
|
|
+
|
|
|
+ for ( j = 0, jl = morphNormals[ i ].vertexNormals.length; j < jl; j ++ ) {
|
|
|
+
|
|
|
+ var srcVertexNormal = morphNormals[ i ].vertexNormals[ j ];
|
|
|
+ var destVertexNormal = {};
|
|
|
+
|
|
|
+ destVertexNormal.a = srcVertexNormal.a.clone();
|
|
|
+ destVertexNormal.b = srcVertexNormal.b.clone();
|
|
|
+ destVertexNormal.c = srcVertexNormal.c.clone();
|
|
|
+
|
|
|
+ morphNormal.vertexNormals.push( destVertexNormal );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ // face normals
|
|
|
+
|
|
|
+ if ( morphNormals[ i ].faceNormals !== undefined ) {
|
|
|
+
|
|
|
+ morphNormal.faceNormals = [];
|
|
|
+
|
|
|
+ for ( j = 0, jl = morphNormals[ i ].faceNormals.length; j < jl; j ++ ) {
|
|
|
+
|
|
|
+ morphNormal.faceNormals.push( morphNormals[ i ].faceNormals[ j ].clone() );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ this.morphNormals.push( morphNormal );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ // skin weights
|
|
|
+
|
|
|
+ var skinWeights = source.skinWeights;
|
|
|
+
|
|
|
+ for ( i = 0, il = skinWeights.length; i < il; i ++ ) {
|
|
|
+
|
|
|
+ this.skinWeights.push( skinWeights[ i ].clone() );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ // skin indices
|
|
|
+
|
|
|
+ var skinIndices = source.skinIndices;
|
|
|
+
|
|
|
+ for ( i = 0, il = skinIndices.length; i < il; i ++ ) {
|
|
|
+
|
|
|
+ this.skinIndices.push( skinIndices[ i ].clone() );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ // line distances
|
|
|
+
|
|
|
+ var lineDistances = source.lineDistances;
|
|
|
+
|
|
|
+ for ( i = 0, il = lineDistances.length; i < il; i ++ ) {
|
|
|
+
|
|
|
+ this.lineDistances.push( lineDistances[ i ] );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ // bounding box
|
|
|
+
|
|
|
+ var boundingBox = source.boundingBox;
|
|
|
+
|
|
|
+ if ( boundingBox !== null ) {
|
|
|
+
|
|
|
+ this.boundingBox = boundingBox.clone();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ // bounding sphere
|
|
|
+
|
|
|
+ var boundingSphere = source.boundingSphere;
|
|
|
+
|
|
|
+ if ( boundingSphere !== null ) {
|
|
|
+
|
|
|
+ this.boundingSphere = boundingSphere.clone();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ // update flags
|
|
|
+
|
|
|
+ this.elementsNeedUpdate = source.elementsNeedUpdate;
|
|
|
+ this.verticesNeedUpdate = source.verticesNeedUpdate;
|
|
|
+ this.uvsNeedUpdate = source.uvsNeedUpdate;
|
|
|
+ this.normalsNeedUpdate = source.normalsNeedUpdate;
|
|
|
+ this.colorsNeedUpdate = source.colorsNeedUpdate;
|
|
|
+ this.lineDistancesNeedUpdate = source.lineDistancesNeedUpdate;
|
|
|
+ this.groupsNeedUpdate = source.groupsNeedUpdate;
|
|
|
+
|
|
|
return this;
|
|
|
|
|
|
},
|