examples/FBXLoader.js
function ( geoNode, skeleton, morphTarget, preTransform ) {

			var geo = new THREE.BufferGeometry();
			if ( geoNode.attrName ) geo.name = geoNode.attrName;

			var geoInfo = this.parseGeoNode( geoNode, skeleton );
			var buffers = this.genBuffers( geoInfo );

			var positionAttribute = new THREE.Float32BufferAttribute( buffers.vertex, 3 );

			preTransform.applyToBufferAttribute( positionAttribute );

			geo.addAttribute( 'position', positionAttribute );

			if ( buffers.colors.length > 0 ) {

				geo.addAttribute( 'color', new THREE.Float32BufferAttribute( buffers.colors, 3 ) );

			}

			if ( skeleton ) {

				geo.addAttribute( 'skinIndex', new THREE.Uint16BufferAttribute( buffers.weightsIndices, 4 ) );

				geo.addAttribute( 'skinWeight', new THREE.Float32BufferAttribute( buffers.vertexWeights, 4 ) );

				// used later to bind the skeleton to the model
				geo.FBX_Deformer = skeleton;

			}

			if ( buffers.normal.length > 0 ) {

				var normalAttribute = new THREE.Float32BufferAttribute( buffers.normal, 3 );

				var normalMatrix = new THREE.Matrix3().getNormalMatrix( preTransform );
				normalMatrix.applyToBufferAttribute( normalAttribute );

				geo.addAttribute( 'normal', normalAttribute );

			}

			buffers.uvs.forEach( function ( uvBuffer, i ) {

				// subsequent uv buffers are called 'uv1', 'uv2', ...
				var name = 'uv' + ( i + 1 ).toString();

				// the first uv buffer is just called 'uv'
				if ( i === 0 ) {

					name = 'uv';

				}

				geo.addAttribute( name, new THREE.Float32BufferAttribute( buffers.uvs[ i ], 2 ) );

			} );

			if ( geoInfo.material && geoInfo.material.mappingType !== 'AllSame' ) {

				// Convert the material indices of each vertex into rendering groups on the geometry.
				var prevMaterialIndex = buffers.materialIndex[ 0 ];
				var startIndex = 0;

				buffers.materialIndex.forEach( function ( currentIndex, i ) {

					if ( currentIndex !== prevMaterialIndex ) {

						geo.addGroup( startIndex, i - startIndex, prevMaterialIndex );

						prevMaterialIndex = currentIndex;
						startIndex = i;

					}

				} );

				// the loop above doesn't add the last group, do that here.
				if ( geo.groups.length > 0 ) {

					var lastGroup = geo.groups[ geo.groups.length - 1 ];
					var lastIndex = lastGroup.start + lastGroup.count;

					if ( lastIndex !== buffers.materialIndex.length ) {

						geo.addGroup( lastIndex, buffers.materialIndex.length - lastIndex, prevMaterialIndex );

					}

				}

				// case where there are multiple materials but the whole geometry is only
				// using one of them
				if ( geo.groups.length === 0 ) {

					geo.addGroup( 0, buffers.materialIndex.length, buffers.materialIndex[ 0 ] );

				}

			}

			this.addMorphTargets( geo, geoNode, morphTarget, preTransform );

			return geo;

		}
function ( geoNode, skeleton, morphTarget, preTransform ) {

			var geo = new THREE.BufferGeometry();
			if ( geoNode.attrName ) geo.name = geoNode.attrName;

			var geoInfo = this.parseGeoNode( geoNode, skeleton );
			var buffers = this.genBuffers( geoInfo );

			var positionAttribute = new THREE.Float32BufferAttribute( buffers.vertex, 3 );

			preTransform.applyToBufferAttribute( positionAttribute );

			geo.addAttribute( 'position', positionAttribute );

			if ( buffers.colors.length > 0 ) {

				geo.addAttribute( 'color', new THREE.Float32BufferAttribute( buffers.colors, 3 ) );

			}

			if ( skeleton ) {

				geo.addAttribute( 'skinIndex', new THREE.Uint16BufferAttribute( buffers.weightsIndices, 4 ) );

				geo.addAttribute( 'skinWeight', new THREE.Float32BufferAttribute( buffers.vertexWeights, 4 ) );

				// used later to bind the skeleton to the model
				geo.FBX_Deformer = skeleton;

			}

			if ( buffers.normal.length > 0 ) {

				var normalAttribute = new THREE.Float32BufferAttribute( buffers.normal, 3 );

				var normalMatrix = new THREE.Matrix3().getNormalMatrix( preTransform );
				normalMatrix.applyToBufferAttribute( normalAttribute );

				geo.addAttribute( 'normal', normalAttribute );

			}

			buffers.uvs.forEach( function ( uvBuffer, i ) {

				// subsequent uv buffers are called 'uv1', 'uv2', ...
				var name = 'uv' + ( i + 1 ).toString();

				// the first uv buffer is just called 'uv'
				if ( i === 0 ) {

					name = 'uv';

				}

				geo.addAttribute( name, new THREE.Float32BufferAttribute( buffers.uvs[ i ], 2 ) );

			} );

			if ( geoInfo.material && geoInfo.material.mappingType !== 'AllSame' ) {

				// Convert the material indices of each vertex into rendering groups on the geometry.
				var prevMaterialIndex = buffers.materialIndex[ 0 ];
				var startIndex = 0;

				buffers.materialIndex.forEach( function ( currentIndex, i ) {

					if ( currentIndex !== prevMaterialIndex ) {

						geo.addGroup( startIndex, i - startIndex, prevMaterialIndex );

						prevMaterialIndex = currentIndex;
						startIndex = i;

					}

				} );

				// the loop above doesn't add the last group, do that here.
				if ( geo.groups.length > 0 ) {

					var lastGroup = geo.groups[ geo.groups.length - 1 ];
					var lastIndex = lastGroup.start + lastGroup.count;

					if ( lastIndex !== buffers.materialIndex.length ) {

						geo.addGroup( lastIndex, buffers.materialIndex.length - lastIndex, prevMaterialIndex );

					}

				}

				// case where there are multiple materials but the whole geometry is only
				// using one of them
				if ( geo.groups.length === 0 ) {

					geo.addGroup( 0, buffers.materialIndex.length, buffers.materialIndex[ 0 ] );

				}

			}

			this.addMorphTargets( geo, geoNode, morphTarget, preTransform );

			return geo;

		}
function ( geoNode , skeleton , morphTarget , preTransform ) { var geo = new THREE . BufferGeometry ( ) ; if ( geoNode . attrName ) geo . name = geoNode . attrName ; var geoInfo = this . parseGeoNode ( geoNode , skeleton ) ; var buffers = this . genBuffers ( geoInfo ) ; var positionAttribute = new THREE . Float32BufferAttribute ( buffers . vertex , 3 ) ; preTransform . applyToBufferAttribute ( positionAttribute ) ; geo . addAttribute ( 'position' , positionAttribute ) ; if ( buffers . colors . length > 0 ) { geo . addAttribute ( 'color' , new THREE . Float32BufferAttribute ( buffers . colors , 3 ) ) ; } if ( skeleton ) { geo . addAttribute ( 'skinIndex' , new THREE . Uint16BufferAttribute ( buffers . weightsIndices , 4 ) ) ; geo . addAttribute ( 'skinWeight' , new THREE . Float32BufferAttribute ( buffers . vertexWeights , 4 ) ) ; // used later to bind the skeleton to the model geo . FBX_Deformer = skeleton ; } if ( buffers . normal . length > 0 ) { var normalAttribute = new THREE . Float32BufferAttribute ( buffers . normal , 3 ) ; var normalMatrix = new THREE . Matrix3 ( ) . getNormalMatrix ( preTransform ) ; normalMatrix . applyToBufferAttribute ( normalAttribute ) ; geo . addAttribute ( 'normal' , normalAttribute ) ; } buffers . uvs . forEach ( function ( uvBuffer , i ) { // subsequent uv buffers are called 'uv1', 'uv2', ... var name = 'uv' + ( i + 1 ) . toString ( ) ; // the first uv buffer is just called 'uv' if ( i === 0 ) { name = 'uv' ; } geo . addAttribute ( name , new THREE . Float32BufferAttribute ( buffers . uvs [ i ] , 2 ) ) ; } ) ; if ( geoInfo . material && geoInfo . material . mappingType !== 'AllSame' ) { // Convert the material indices of each vertex into rendering groups on the geometry. var prevMaterialIndex = buffers . materialIndex [ 0 ] ; var startIndex = 0 ; buffers . materialIndex . forEach ( function ( currentIndex , i ) { if ( currentIndex !== prevMaterialIndex ) { geo . addGroup ( startIndex , i - startIndex , prevMaterialIndex ) ; prevMaterialIndex = currentIndex ; startIndex = i ; } } ) ; // the loop above doesn't add the last group, do that here. if ( geo . groups . length > 0 ) { var lastGroup = geo . groups [ geo . groups . length - 1 ] ; var lastIndex = lastGroup . start + lastGroup . count ; if ( lastIndex !== buffers . materialIndex . length ) { geo . addGroup ( lastIndex , buffers . materialIndex . length - lastIndex , prevMaterialIndex ) ; } } // case where there are multiple materials but the whole geometry is only // using one of them if ( geo . groups . length === 0 ) { geo . addGroup ( 0 , buffers . materialIndex . length , buffers . materialIndex [ 0 ] ) ; } } this . addMorphTargets ( geo , geoNode , morphTarget , preTransform ) ; return geo ; }
Generate a THREE.BufferGeometry from a node in FBXTree.Objects.Geometry
Generate a THREE . BufferGeometry from a node in FBXTree . Objects . Geometry