@@ -20,7 +20,7 @@ import { _Math } from '../math/Math';
2020 */
2121
2222var count = 0 ;
23- function GeometryIdCount ( ) { return count ++ ; } ;
23+ function GeometryIdCount ( ) { return count ++ ; }
2424
2525function Geometry ( ) {
2626
@@ -1200,36 +1200,59 @@ Geometry.prototype = {
12001200
12011201 copy : function ( source ) {
12021202
1203+ var i , il , j , jl , k , kl ;
1204+
1205+ // reset
1206+
12031207 this . vertices = [ ] ;
1204- this . faces = [ ] ;
1205- this . faceVertexUvs = [ [ ] ] ;
12061208 this . colors = [ ] ;
1209+ this . faces = [ ] ;
1210+ this . faceVertexUvs = [ [ ] ] ;
1211+ this . morphTargets = [ ] ;
1212+ this . morphNormals = [ ] ;
1213+ this . skinWeights = [ ] ;
1214+ this . skinIndices = [ ] ;
1215+ this . lineDistances = [ ] ;
1216+ this . boundingBox = null ;
1217+ this . boundingSphere = null ;
1218+
1219+ // name
1220+
1221+ this . name = source . name ;
1222+
1223+ // vertices
12071224
12081225 var vertices = source . vertices ;
12091226
1210- for ( var i = 0 , il = vertices . length ; i < il ; i ++ ) {
1227+ for ( i = 0 , il = vertices . length ; i < il ; i ++ ) {
12111228
12121229 this . vertices . push ( vertices [ i ] . clone ( ) ) ;
12131230
12141231 }
12151232
1233+ // colors
1234+
12161235 var colors = source . colors ;
12171236
1218- for ( var i = 0 , il = colors . length ; i < il ; i ++ ) {
1237+ for ( i = 0 , il = colors . length ; i < il ; i ++ ) {
12191238
12201239 this . colors . push ( colors [ i ] . clone ( ) ) ;
12211240
12221241 }
12231242
1243+ // faces
1244+
12241245 var faces = source . faces ;
12251246
1226- for ( var i = 0 , il = faces . length ; i < il ; i ++ ) {
1247+ for ( i = 0 , il = faces . length ; i < il ; i ++ ) {
12271248
12281249 this . faces . push ( faces [ i ] . clone ( ) ) ;
12291250
12301251 }
12311252
1232- for ( var i = 0 , il = source . faceVertexUvs . length ; i < il ; i ++ ) {
1253+ // face vertex uvs
1254+
1255+ for ( i = 0 , il = source . faceVertexUvs . length ; i < il ; i ++ ) {
12331256
12341257 var faceVertexUvs = source . faceVertexUvs [ i ] ;
12351258
@@ -1239,11 +1262,11 @@ Geometry.prototype = {
12391262
12401263 }
12411264
1242- for ( var j = 0 , jl = faceVertexUvs . length ; j < jl ; j ++ ) {
1265+ for ( j = 0 , jl = faceVertexUvs . length ; j < jl ; j ++ ) {
12431266
12441267 var uvs = faceVertexUvs [ j ] , uvsCopy = [ ] ;
12451268
1246- for ( var k = 0 , kl = uvs . length ; k < kl ; k ++ ) {
1269+ for ( k = 0 , kl = uvs . length ; k < kl ; k ++ ) {
12471270
12481271 var uv = uvs [ k ] ;
12491272
@@ -1257,6 +1280,154 @@ Geometry.prototype = {
12571280
12581281 }
12591282
1283+ // morph targets
1284+
1285+ var morphTargets = source . morphTargets ;
1286+
1287+ for ( i = 0 , il = morphTargets . length ; i < il ; i ++ ) {
1288+
1289+ var morphTarget = { } ;
1290+ morphTarget . name = morphTargets [ i ] . name ;
1291+
1292+ // vertices
1293+
1294+ if ( morphTargets [ i ] . vertices !== undefined ) {
1295+
1296+ morphTarget . vertices = [ ] ;
1297+
1298+ for ( j = 0 , jl = morphTargets [ i ] . vertices . length ; j < jl ; j ++ ) {
1299+
1300+ morphTarget . vertices . push ( morphTargets [ i ] . vertices [ j ] . clone ( ) ) ;
1301+
1302+ }
1303+
1304+ }
1305+
1306+ // normals
1307+
1308+ if ( morphTargets [ i ] . normals !== undefined ) {
1309+
1310+ morphTarget . normals = [ ] ;
1311+
1312+ for ( j = 0 , jl = morphTargets [ i ] . normals . length ; j < jl ; j ++ ) {
1313+
1314+ morphTarget . normals . push ( morphTargets [ i ] . normals [ j ] . clone ( ) ) ;
1315+
1316+ }
1317+
1318+ }
1319+
1320+ this . morphTargets . push ( morphTarget ) ;
1321+
1322+ }
1323+
1324+ // morph normals
1325+
1326+ var morphNormals = source . morphNormals ;
1327+
1328+ for ( i = 0 , il = morphNormals . length ; i < il ; i ++ ) {
1329+
1330+ var morphNormal = { } ;
1331+
1332+ // vertex normals
1333+
1334+ if ( morphNormals [ i ] . vertexNormals !== undefined ) {
1335+
1336+ morphNormal . vertexNormals = [ ] ;
1337+
1338+ for ( j = 0 , jl = morphNormals [ i ] . vertexNormals . length ; j < jl ; j ++ ) {
1339+
1340+ var srcVertexNormal = morphNormals [ i ] . vertexNormals [ j ] ;
1341+ var destVertexNormal = { } ;
1342+
1343+ destVertexNormal . a = srcVertexNormal . a . clone ( ) ;
1344+ destVertexNormal . b = srcVertexNormal . b . clone ( ) ;
1345+ destVertexNormal . c = srcVertexNormal . c . clone ( ) ;
1346+
1347+ morphNormal . vertexNormals . push ( destVertexNormal ) ;
1348+
1349+ }
1350+
1351+ }
1352+
1353+ // face normals
1354+
1355+ if ( morphNormals [ i ] . faceNormals !== undefined ) {
1356+
1357+ morphNormal . faceNormals = [ ] ;
1358+
1359+ for ( j = 0 , jl = morphNormals [ i ] . faceNormals . length ; j < jl ; j ++ ) {
1360+
1361+ morphNormal . faceNormals . push ( morphNormals [ i ] . faceNormals [ j ] . clone ( ) ) ;
1362+
1363+ }
1364+
1365+ }
1366+
1367+ this . morphNormals . push ( morphNormal ) ;
1368+
1369+ }
1370+
1371+ // skin weights
1372+
1373+ var skinWeights = source . skinWeights ;
1374+
1375+ for ( i = 0 , il = skinWeights . length ; i < il ; i ++ ) {
1376+
1377+ this . skinWeights . push ( skinWeights [ i ] . clone ( ) ) ;
1378+
1379+ }
1380+
1381+ // skin indices
1382+
1383+ var skinIndices = source . skinIndices ;
1384+
1385+ for ( i = 0 , il = skinIndices . length ; i < il ; i ++ ) {
1386+
1387+ this . skinIndices . push ( skinIndices [ i ] . clone ( ) ) ;
1388+
1389+ }
1390+
1391+ // line distances
1392+
1393+ var lineDistances = source . lineDistances ;
1394+
1395+ for ( i = 0 , il = lineDistances . length ; i < il ; i ++ ) {
1396+
1397+ this . lineDistances . push ( lineDistances [ i ] ) ;
1398+
1399+ }
1400+
1401+ // bounding box
1402+
1403+ var boundingBox = source . boundingBox ;
1404+
1405+ if ( boundingBox !== null ) {
1406+
1407+ this . boundingBox = boundingBox . clone ( ) ;
1408+
1409+ }
1410+
1411+ // bounding sphere
1412+
1413+ var boundingSphere = source . boundingSphere ;
1414+
1415+ if ( boundingSphere !== null ) {
1416+
1417+ this . boundingSphere = boundingSphere . clone ( ) ;
1418+
1419+ }
1420+
1421+ // update flags
1422+
1423+ this . elementsNeedUpdate = source . elementsNeedUpdate ;
1424+ this . verticesNeedUpdate = source . verticesNeedUpdate ;
1425+ this . uvsNeedUpdate = source . uvsNeedUpdate ;
1426+ this . normalsNeedUpdate = source . normalsNeedUpdate ;
1427+ this . colorsNeedUpdate = source . colorsNeedUpdate ;
1428+ this . lineDistancesNeedUpdate = source . lineDistancesNeedUpdate ;
1429+ this . groupsNeedUpdate = source . groupsNeedUpdate ;
1430+
12601431 return this ;
12611432
12621433 } ,
0 commit comments