|
@@ -163,7 +163,9 @@
|
|
|
* @type {[number, number, string][]}
|
|
|
*/
|
|
|
var connectionArray = FBXTree.Connections.properties.connections;
|
|
|
- connectionArray.forEach( function ( connection ) {
|
|
|
+ for ( var connectionArrayIndex = 0, connectionArrayLength = connectionArray.length; connectionArrayIndex < connectionArrayLength; ++ connectionArrayIndex ) {
|
|
|
+
|
|
|
+ var connection = connectionArray[ connectionArrayIndex ];
|
|
|
|
|
|
if ( ! connectionMap.has( connection[ 0 ] ) ) {
|
|
|
|
|
@@ -189,7 +191,7 @@
|
|
|
var childRelationship = { ID: connection[ 0 ], relationship: connection[ 2 ] };
|
|
|
connectionMap.get( connection[ 1 ] ).children.push( childRelationship );
|
|
|
|
|
|
- } );
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -370,7 +372,9 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
- childrenRelationships.forEach( function ( relationship ) {
|
|
|
+ for ( var childrenRelationshipsIndex = 0, childrenRelationshipsLength = childrenRelationships.length; childrenRelationshipsIndex < childrenRelationshipsLength; ++ childrenRelationshipsIndex ) {
|
|
|
+
|
|
|
+ var relationship = childrenRelationships[ childrenRelationshipsIndex ];
|
|
|
|
|
|
var type = relationship.relationship;
|
|
|
switch ( type ) {
|
|
@@ -389,7 +393,7 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
- } );
|
|
|
+ }
|
|
|
|
|
|
return parameters;
|
|
|
|
|
@@ -440,7 +444,9 @@
|
|
|
|
|
|
var subDeformers = new Map();
|
|
|
var subDeformerArray = [];
|
|
|
- connections.children.forEach( function ( child ) {
|
|
|
+ for ( var childrenIndex = 0, childrenLength = connections.children.length; childrenIndex < childrenLength; ++ childrenIndex ) {
|
|
|
+
|
|
|
+ var child = connections.children[ childrenIndex ];
|
|
|
|
|
|
var subDeformerNode = DeformerNodes[ child.ID ];
|
|
|
var subDeformer = {
|
|
@@ -454,7 +460,7 @@
|
|
|
subDeformers.set( child.ID, subDeformer );
|
|
|
subDeformerArray.push( subDeformer );
|
|
|
|
|
|
- } );
|
|
|
+ }
|
|
|
|
|
|
return {
|
|
|
map: subDeformers,
|
|
@@ -812,11 +818,11 @@
|
|
|
// we expect. So we create an intermediate buffer that points to the index in the buffer,
|
|
|
// for conforming with the other functions we've written for other data.
|
|
|
var materialIndices = [];
|
|
|
- materialIndexBuffer.forEach( function ( materialIndex, index ) {
|
|
|
+ for ( var materialIndexBufferIndex = 0, materialIndexBufferLength = materialIndexBuffer.length; materialIndexBufferIndex < materialIndexBufferLength; ++ materialIndexBufferIndex ) {
|
|
|
|
|
|
- materialIndices.push( index );
|
|
|
+ materialIndices.push( materialIndexBufferIndex );
|
|
|
|
|
|
- } );
|
|
|
+ }
|
|
|
|
|
|
return {
|
|
|
dataSize: 1,
|
|
@@ -978,12 +984,14 @@
|
|
|
var vertices = curve.getPoints( controlPoints.length * 1.5 );
|
|
|
|
|
|
var vertexBuffer = [];
|
|
|
- vertices.forEach( function ( position ) {
|
|
|
+ for ( var verticesIndex = 0, verticesLength = vertices.length; verticesIndex < verticesLength; ++ verticesIndex ) {
|
|
|
+
|
|
|
+ var position = vertices[ verticesIndex ];
|
|
|
|
|
|
var array = position.toArray();
|
|
|
vertexBuffer = vertexBuffer.concat( array );
|
|
|
|
|
|
- } );
|
|
|
+ }
|
|
|
|
|
|
var geometry = new THREE.BufferGeometry();
|
|
|
geometry.addAttribute( 'position', new THREE.BufferAttribute( new Float32Array( vertexBuffer ), 3 ) );
|
|
@@ -1066,7 +1074,9 @@
|
|
|
*/
|
|
|
var materials = [];
|
|
|
|
|
|
- conns.children.forEach( function ( child ) {
|
|
|
+ for ( var childrenIndex = 0, childrenLength = conns.children.length; childrenIndex < childrenLength; ++ childrenIndex ) {
|
|
|
+
|
|
|
+ var child = conns.children[ childrenIndex ];
|
|
|
|
|
|
if ( geometryMap.has( child.ID ) ) {
|
|
|
|
|
@@ -1080,7 +1090,7 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
- } );
|
|
|
+ }
|
|
|
if ( materials.length > 1 ) {
|
|
|
|
|
|
material = new THREE.MultiMaterial( materials );
|
|
@@ -1096,11 +1106,13 @@
|
|
|
}
|
|
|
if ( geometry.FBX_Deformer ) {
|
|
|
|
|
|
- materials.forEach( function ( material ) {
|
|
|
+ for ( var materialsIndex = 0, materialsLength = materials.length; materialsIndex < materialsLength; ++ materialsIndex ) {
|
|
|
+
|
|
|
+ var material = materials[ materialsIndex ];
|
|
|
|
|
|
material.skinning = true;
|
|
|
|
|
|
- } );
|
|
|
+ }
|
|
|
material.skinning = true;
|
|
|
model = new THREE.SkinnedMesh( geometry, material );
|
|
|
|
|
@@ -1114,7 +1126,9 @@
|
|
|
case "NurbsCurve":
|
|
|
var geometry = null;
|
|
|
|
|
|
- conns.children.forEach( function ( child ) {
|
|
|
+ for ( var childrenIndex = 0, childrenLength = conns.children.length; childrenIndex < childrenLength; ++ childrenIndex ) {
|
|
|
+
|
|
|
+ var child = conns.children[ childrenIndex ];
|
|
|
|
|
|
if ( geometryMap.has( child.ID ) ) {
|
|
|
|
|
@@ -1122,7 +1136,7 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
- } );
|
|
|
+ }
|
|
|
|
|
|
// FBX does not list materials for Nurbs lines, so we'll just put our own in here.
|
|
|
material = new THREE.LineBasicMaterial( { color: 0x3300ff, linewidth: 5 } );
|
|
@@ -1145,7 +1159,9 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
- modelArray.forEach( function ( model ) {
|
|
|
+ for ( var modelArrayIndex = 0, modelArrayLength = modelArray.length; modelArrayIndex < modelArrayLength; ++ modelArrayIndex ) {
|
|
|
+
|
|
|
+ var model = modelArray[ modelArrayIndex ];
|
|
|
|
|
|
var node = ModelNode[ model.FBX_ID ];
|
|
|
|
|
@@ -1195,7 +1211,7 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
- } );
|
|
|
+ }
|
|
|
|
|
|
|
|
|
// Now with the bones created, we can update the skeletons and bind them to the skinned meshes.
|
|
@@ -1218,19 +1234,24 @@
|
|
|
var PoseNode = BindPoseNode.subNodes.PoseNode;
|
|
|
var worldMatrices = new Map();
|
|
|
|
|
|
- PoseNode.forEach( function ( node ) {
|
|
|
+ for ( var PoseNodeIndex = 0, PoseNodeLength = PoseNode.length; PoseNodeIndex < PoseNodeLength; ++ PoseNodeIndex ) {
|
|
|
+
|
|
|
+ var node = PoseNode[ PoseNodeIndex ];
|
|
|
|
|
|
var rawMatWrd = parseMatrixArray( node.subNodes.Matrix.properties.a );
|
|
|
|
|
|
worldMatrices.set( parseInt( node.id ), rawMatWrd );
|
|
|
|
|
|
- } );
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
|
deformerMap.forEach( function ( deformer, FBX_ID ) {
|
|
|
|
|
|
- deformer.array.forEach( function ( subDeformer, subDeformerIndex ) {
|
|
|
+ for ( var deformerArrayIndex = 0, deformerArrayLength = deformer.array.length; deformerArrayIndex < deformerArrayLength; ++ deformerArrayIndex ) {
|
|
|
+
|
|
|
+ //var subDeformer = deformer.array[ deformerArrayIndex ];
|
|
|
+ var subDeformerIndex = deformerArrayIndex;
|
|
|
|
|
|
/**
|
|
|
* @type {THREE.Bone}
|
|
@@ -1238,18 +1259,20 @@
|
|
|
var bone = deformer.bones[ subDeformerIndex ];
|
|
|
if ( ! worldMatrices.has( bone.FBX_ID ) ) {
|
|
|
|
|
|
- return;
|
|
|
+ break;
|
|
|
|
|
|
}
|
|
|
var mat = worldMatrices.get( bone.FBX_ID );
|
|
|
bone.matrixWorld.copy( mat );
|
|
|
|
|
|
- } );
|
|
|
+ }
|
|
|
|
|
|
// Now that skeleton is in bind pose, bind to model.
|
|
|
deformer.skeleton = new THREE.Skeleton( deformer.bones );
|
|
|
var conns = connections.get( FBX_ID );
|
|
|
- conns.parents.forEach( function ( parent ) {
|
|
|
+ for ( var parentsIndex = 0, parentsLength = conns.parents.length; parentsIndex < parentsLength; ++ parentsIndex ) {
|
|
|
+
|
|
|
+ var parent = conns.parents[ parentsIndex ];
|
|
|
|
|
|
if ( geometryMap.has( parent.ID ) ) {
|
|
|
|
|
@@ -1270,13 +1293,15 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
- } );
|
|
|
+ }
|
|
|
|
|
|
} );
|
|
|
|
|
|
// Skeleton is now bound, we are now free to set up the
|
|
|
// scene graph.
|
|
|
- modelArray.forEach( function ( model ) {
|
|
|
+ for ( var modelArrayIndex = 0, modelArrayLength = modelArray.length; modelArrayIndex < modelArrayLength; ++ modelArrayIndex ) {
|
|
|
+
|
|
|
+ var model = modelArray[ modelArrayIndex ];
|
|
|
|
|
|
var node = ModelNode[ model.FBX_ID ];
|
|
|
|
|
@@ -1304,7 +1329,7 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
- } );
|
|
|
+ }
|
|
|
|
|
|
// Silly hack with the animation parsing. We're gonna pretend the scene graph has a skeleton
|
|
|
// to attach animations to, since FBXs treat animations as animations for the entire scene,
|
|
@@ -2013,7 +2038,9 @@
|
|
|
var currentLayer = returnObject.layers.get( children[ childIndex ].ID );
|
|
|
layers.push( currentLayer );
|
|
|
|
|
|
- currentLayer.forEach( function ( layer ) {
|
|
|
+ for ( var currentLayerIndex = 0, currentLayerLength = currentLayer.length; currentLayerIndex < currentLayerLength; ++ currentLayerIndex ) {
|
|
|
+
|
|
|
+ var layer = currentLayer[ currentLayerIndex ];
|
|
|
|
|
|
if ( layer ) {
|
|
|
|
|
@@ -2228,7 +2255,7 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
- } );
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -2771,7 +2798,9 @@
|
|
|
|
|
|
var bones = group.skeleton.bones;
|
|
|
|
|
|
- bones.forEach( function ( bone ) {
|
|
|
+ for ( var bonesIndex = 0, bonesLength = bones.length; bonesIndex < bonesLength; ++ bonesIndex ) {
|
|
|
+
|
|
|
+ var bone = bones[ bonesIndex ];
|
|
|
|
|
|
var name = bone.name.replace( /.*:/, '' );
|
|
|
var parentIndex = bones.findIndex( function ( parentBone ) {
|
|
@@ -2781,15 +2810,20 @@
|
|
|
} );
|
|
|
animationData.hierarchy.push( { parent: parentIndex, name: name, keys: [] } );
|
|
|
|
|
|
- } );
|
|
|
+ }
|
|
|
|
|
|
for ( var frame = 0; frame < stack.frames; frame ++ ) {
|
|
|
|
|
|
- bones.forEach( function ( bone, boneIndex ) {
|
|
|
+ for ( var bonesIndex = 0, bonesLength = bones.length; bonesIndex < bonesLength; ++ bonesIndex ) {
|
|
|
+
|
|
|
+ var bone = bones[ bonesIndex ];
|
|
|
+ var boneIndex = bonesIndex;
|
|
|
|
|
|
var animationNode = stack.layers[ 0 ][ boneIndex ];
|
|
|
|
|
|
- animationData.hierarchy.forEach( function ( node ) {
|
|
|
+ for ( var hierarchyIndex = 0, hierarchyLength = animationData.hierarchy.length; hierarchyIndex < hierarchyLength; ++ hierarchyIndex ) {
|
|
|
+
|
|
|
+ var node = animationData.hierarchy[ hierarchyIndex ];
|
|
|
|
|
|
if ( node.name === bone.name ) {
|
|
|
|
|
@@ -2797,9 +2831,9 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
- } );
|
|
|
+ }
|
|
|
|
|
|
- } );
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -3042,7 +3076,9 @@
|
|
|
var skinIndexBuffer = [];
|
|
|
var skinWeightBuffer = [];
|
|
|
|
|
|
- this.vertices.forEach( function ( vertex ) {
|
|
|
+ for ( var verticesIndex = 0, verticesLength = this.vertices.length; verticesIndex < verticesLength; ++ verticesIndex ) {
|
|
|
+
|
|
|
+ var vertex = this.vertices[ verticesIndex ];
|
|
|
|
|
|
var flatVertex = vertex.flattenToBuffers();
|
|
|
vertexBuffer = vertexBuffer.concat( flatVertex.vertexBuffer );
|
|
@@ -3051,7 +3087,7 @@
|
|
|
skinIndexBuffer = skinIndexBuffer.concat( flatVertex.skinIndexBuffer );
|
|
|
skinWeightBuffer = skinWeightBuffer.concat( flatVertex.skinWeightBuffer );
|
|
|
|
|
|
- } );
|
|
|
+ }
|
|
|
|
|
|
return {
|
|
|
vertexBuffer: vertexBuffer,
|
|
@@ -3122,8 +3158,9 @@
|
|
|
|
|
|
var materialIndex = this.materialIndex;
|
|
|
|
|
|
- this.triangles.forEach( function ( triangle ) {
|
|
|
+ for ( var triangleIndex = 0, triangleLength = this.triangles.length; triangleIndex < triangleLength; ++ triangleIndex ) {
|
|
|
|
|
|
+ var triangle = this.triangles[ triangleIndex ];
|
|
|
var flatTriangle = triangle.flattenToBuffers();
|
|
|
vertexBuffer = vertexBuffer.concat( flatTriangle.vertexBuffer );
|
|
|
normalBuffer = normalBuffer.concat( flatTriangle.normalBuffer );
|
|
@@ -3132,7 +3169,7 @@
|
|
|
skinWeightBuffer = skinWeightBuffer.concat( flatTriangle.skinWeightBuffer );
|
|
|
materialIndexBuffer = materialIndexBuffer.concat( [ materialIndex, materialIndex, materialIndex ] );
|
|
|
|
|
|
- } );
|
|
|
+ }
|
|
|
|
|
|
return {
|
|
|
vertexBuffer: vertexBuffer,
|
|
@@ -3179,8 +3216,9 @@
|
|
|
|
|
|
var materialIndexBuffer = [];
|
|
|
|
|
|
- this.faces.forEach( function ( face ) {
|
|
|
+ for ( var faceIndex = 0, faceLength = this.faces.length; faceIndex < faceLength; ++ faceIndex ) {
|
|
|
|
|
|
+ var face = this.faces[ faceIndex ];
|
|
|
var flatFace = face.flattenToBuffers();
|
|
|
vertexBuffer = vertexBuffer.concat( flatFace.vertexBuffer );
|
|
|
normalBuffer = normalBuffer.concat( flatFace.normalBuffer );
|
|
@@ -3189,7 +3227,7 @@
|
|
|
skinWeightBuffer = skinWeightBuffer.concat( flatFace.skinWeightBuffer );
|
|
|
materialIndexBuffer = materialIndexBuffer.concat( flatFace.materialIndexBuffer );
|
|
|
|
|
|
- } );
|
|
|
+ }
|
|
|
|
|
|
return {
|
|
|
vertexBuffer: vertexBuffer,
|