فهرست منبع

convert whitespaces into tab

yamahigashi 9 سال پیش
والد
کامیت
7fec1b1851
1فایلهای تغییر یافته به همراه2058 افزوده شده و 1647 حذف شده
  1. 2058 1647
      examples/js/loaders/FBXLoader.js

+ 2058 - 1647
examples/js/loaders/FBXLoader.js

@@ -16,2339 +16,2750 @@
 
 ( function() {
 
-    THREE.FBXLoader = function ( showStatus, manager ) {
+	THREE.FBXLoader = function ( showStatus, manager ) {
 
-        THREE.Loader.call( this, showStatus );
-        this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager;
-        this.textureLoader = null;
-        this.textureBasePath = null;
+		THREE.Loader.call( this, showStatus );
+		this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager;
+		this.textureLoader = null;
+		this.textureBasePath = null;
 
-    };
+	};
 
-    THREE.FBXLoader.prototype = Object.create( THREE.Loader.prototype );
+	THREE.FBXLoader.prototype = Object.create( THREE.Loader.prototype );
 
+	THREE.FBXLoader.prototype.constructor = THREE.FBXLoader;
 
-    THREE.FBXLoader.prototype.constructor = THREE.FBXLoader;
+	THREE.FBXLoader.prototype.load = function ( url, onLoad, onProgress, onError ) {
 
-    THREE.FBXLoader.prototype.load = function ( url, onLoad, onProgress, onError ) {
+		var scope = this;
 
-        var scope = this;
+		var loader = new THREE.XHRLoader( scope.manager );
+		// loader.setCrossOrigin( this.crossOrigin );
+		loader.load( url, function ( text ) {
 
-        var loader = new THREE.XHRLoader( scope.manager );
-        // loader.setCrossOrigin( this.crossOrigin );
-        loader.load( url, function ( text ) {
+			if ( ! scope.isFbxFormatASCII( text ) ) {
 
-            if(  !scope.isFbxFormatASCII( text ) ){
-                console.warn( 'FBXLoader: !!! FBX Binary format not supported !!!' );
-            } else if ( !scope.isFbxVersionSupported( text ) ) {
-                console.warn( 'FBXLoader: !!! FBX Version below 7 not supported !!!' );
-            } else {
-                scope.textureBasePath = scope.extractUrlBase( url );
-                parser = new FBXParser();
-                var nodes = parser.parse( text );
-                onLoad( scope.parse( nodes ) );
-            }
+				console.warn( 'FBXLoader: !!! FBX Binary format not supported !!!' );
 
-        }, onProgress, onError );
+			} else if ( ! scope.isFbxVersionSupported( text ) ) {
 
-    };
+				console.warn( 'FBXLoader: !!! FBX Version below 7 not supported !!!' );
 
-    THREE.FBXLoader.prototype.setCrossOrigin = function ( value ) {
+			} else {
 
-        this.crossOrigin = value;
+				scope.textureBasePath = scope.extractUrlBase( url );
+				parser = new FBXParser();
+				var nodes = parser.parse( text );
+				onLoad( scope.parse( nodes ) );
 
-    };
+			}
 
-    THREE.FBXLoader.prototype.isFbxFormatASCII = function ( body ) {
+		}, onProgress, onError );
 
-        CORRECT = ['K', 'a', 'y', 'd', 'a', 'r', 'a', '\\',  'F', 'B', 'X', '\\',  'B', 'i', 'n', 'a', 'r', 'y', '\\',  '\\' ];
+	};
 
-        var cursor = 0;
-        var read = function( offset ){
-            var result = body[ offset - 1 ];
-            body = body.slice( cursor + offset );
-            cursor++;
-            return result;
-        };
+	THREE.FBXLoader.prototype.setCrossOrigin = function ( value ) {
 
-        for (var i=0; i < CORRECT.length; ++i) {
-            num = read( 1 );
-            if ( num == CORRECT[i] ){
-                return false;
-            }
-        }
+		this.crossOrigin = value;
 
-        return true;
-    };
+	};
 
-    THREE.FBXLoader.prototype.isFbxVersionSupported = function ( body ){
+	THREE.FBXLoader.prototype.isFbxFormatASCII = function ( body ) {
 
-        var versionExp = /FBXVersion: (\d+)/;
-        match = body.match( versionExp );
-        if ( match ){
-            var version = parseInt( match[1] );
-            console.log( 'FBXLoader: FBX version ' + version );
-            return version >= 7000;
-        }
-        return false;
-    };
+		CORRECT = [ 'K', 'a', 'y', 'd', 'a', 'r', 'a', '\\', 'F', 'B', 'X', '\\', 'B', 'i', 'n', 'a', 'r', 'y', '\\', '\\' ];
 
-    THREE.FBXLoader.prototype.parse = function ( allNodes ) {
+		var cursor = 0;
+		var read = function ( offset ) {
 
-        var scope = this;
+			var result = body[ offset - 1 ];
+			body = body.slice( cursor + offset );
+			cursor ++;
+			return result;
 
-        console.time( 'FBXLoader: ObjectParser' );
-        scope.hierarchy  = ( new Bones() ).parseHierarchy( allNodes );
-        scope.weights    = ( new Weights() ).parse( allNodes, scope.hierarchy );
-        scope.animations = ( new Animation() ).parse( allNodes, scope.hierarchy );
-        scope.textures   = ( new Textures() ).parse( allNodes, scope.hierarchy );
-        console.timeEnd( 'FBXLoader: ObjectParser' );
+		};
 
-        console.time( 'FBXLoader: GeometryParser' );
-        geometries = this.parseGeometries( allNodes );
-        console.timeEnd( 'FBXLoader: GeometryParser' );
+		for ( var i = 0; i < CORRECT.length; ++ i ) {
 
-        var container = new THREE.Object3D();
-        for (var i=0; i < geometries.length; ++i) {
+			num = read( 1 );
+			if ( num == CORRECT[ i ] ) {
 
-            if ( geometries[i] === undefined ){ continue; }
+				return false;
 
-            container.add( geometries[i] );
+			}
 
-            //wireframe = new THREE.WireframeHelper( geometries[i], 0x00ff00 );
-            //container.add( wireframe );
+		}
 
-            //vnh = new THREE.VertexNormalsHelper( geometries[i], 0.6 );
-            //container.add( vnh );
+		return true;
 
-            //skh = new THREE.SkeletonHelper( geometries[i] );
-            //container.add( skh );
+	};
 
-            // container.add( new THREE.BoxHelper( geometries[i] ) );
-        }
+	THREE.FBXLoader.prototype.isFbxVersionSupported = function ( body ) {
 
-        console.timeEnd( 'FBXLoader: total' );
-        return container;
+		var versionExp = /FBXVersion: (\d+)/;
+		match = body.match( versionExp );
+		if ( match ) {
 
-    };
+			var version = parseInt( match[ 1 ] );
+			console.log( 'FBXLoader: FBX version ' + version );
+			return version >= 7000;
 
-    THREE.FBXLoader.prototype.parseGeometries = function ( node ) {
+		}
+		return false;
 
-        // has not geo, return []
-        if ( !( 'Geometry' in node.Objects.subNodes ) ) { return []; }
+	};
 
-        // has many
-        var geoCount = 0;
-        for ( var geo in node.Objects.subNodes.Geometry ) {
-            if ( geo.match( /^\d+$/ )){ geoCount++; }
-        }
+	THREE.FBXLoader.prototype.parse = function ( allNodes ) {
 
-        var res = [];
-        if ( geoCount > 0 ){
+		var scope = this;
 
-            for ( geo in node.Objects.subNodes.Geometry ) {
-                if ( node.Objects.subNodes.Geometry[geo].attrType === 'Mesh' ) {
-                    res.push( this.parseGeometry( node.Objects.subNodes.Geometry[geo], node ) );
-                }
-            }
+		console.time( 'FBXLoader: ObjectParser' );
+		scope.hierarchy = ( new Bones() ).parseHierarchy( allNodes );
+		scope.weights	= ( new Weights() ).parse( allNodes, scope.hierarchy );
+		scope.animations = ( new Animation() ).parse( allNodes, scope.hierarchy );
+		scope.textures = ( new Textures() ).parse( allNodes, scope.hierarchy );
+		console.timeEnd( 'FBXLoader: ObjectParser' );
 
-        } else {
+		console.time( 'FBXLoader: GeometryParser' );
+		geometries = this.parseGeometries( allNodes );
+		console.timeEnd( 'FBXLoader: GeometryParser' );
 
-            res.push( this.parseGeometry( node.Objects.subNodes.Geometry, node ) );
+		var container = new THREE.Object3D();
+		for ( var i = 0; i < geometries.length; ++ i ) {
 
-        }
+			if ( geometries[ i ] === undefined ) {
 
-        return res;
+				continue;
 
-    };
+			}
 
-    THREE.FBXLoader.prototype.parseGeometry = function ( node, nodes ) {
+			container.add( geometries[ i ] );
 
-        geo = ( new Geometry() ).parse( node );
-        geo.addBones( this.hierarchy.hierarchy );
+			//wireframe = new THREE.WireframeHelper( geometries[i], 0x00ff00 );
+			//container.add( wireframe );
 
-        //*
-        var geometry = new THREE.BufferGeometry();
-        geometry.name = geo.name;
-        geometry.addAttribute( 'position', new THREE.BufferAttribute( new Float32Array( geo.vertices ), 3 ) );
+			//vnh = new THREE.VertexNormalsHelper( geometries[i], 0.6 );
+			//container.add( vnh );
 
-        if ( geo.normals !== undefined && geo.normals.length > 0 ) {
-            geometry.addAttribute( 'normal', new THREE.BufferAttribute( new Float32Array( geo.normals ), 3 ) );
-        }
+			//skh = new THREE.SkeletonHelper( geometries[i] );
+			//container.add( skh );
 
-        if ( geo.uvs !== undefined && geo.uvs.length > 0 ) {
-            geometry.addAttribute( 'uv', new THREE.BufferAttribute( new Float32Array( geo.uvs ), 2 ) );
-        }
+			// container.add( new THREE.BoxHelper( geometries[i] ) );
 
-        if ( geo.indices !== undefined && geo.indices.length > 65535 ){
-            geometry.setIndex( new THREE.BufferAttribute( new Uint32Array( geo.indices ), 1 ) );
-        } else if ( geo.indices !== undefined ) {
-            geometry.setIndex( new THREE.BufferAttribute( new Uint16Array( geo.indices ), 1 ) );
-        }
+		}
 
-        geometry.verticesNeedUpdate = true;
-        geometry.computeBoundingSphere();
-        geometry.computeBoundingBox();
+		console.timeEnd( 'FBXLoader: total' );
+		return container;
 
-        var texture;
-        var texs = this.textures.getById( nodes.searchConnectionParent( geo.id ) );
-        if ( texs !== undefined && texs.length > 0 ){
-            if ( this.textureLoader === null ){
-                this.textureLoader = new THREE.TextureLoader();
-            }
-            // TODO: texture & material support
-            texture = this.textureLoader.load( this.textureBasePath + '/' + texs[0].fileName );
-        }
+	};
 
-        var material;
-        if ( texture !== undefined ){
+	THREE.FBXLoader.prototype.parseGeometries = function ( node ) {
 
-            material = new THREE.MeshBasicMaterial( { map: texture } );
+		// has not geo, return []
+		if ( ! ( 'Geometry' in node.Objects.subNodes ) ) {
 
-        } else {
+			return [];
 
-            material = new THREE.MeshBasicMaterial( { color: 0x3300ff } );
+		}
 
-        }
+		// has many
+		var geoCount = 0;
+		for ( var geo in node.Objects.subNodes.Geometry ) {
 
-        geometry = new THREE.Geometry().fromBufferGeometry( geometry );
-        geometry.bones = geo.bones;
-        geometry.skinIndices = this.weights.skinIndices;
-        geometry.skinWeights = this.weights.skinWeights;
+			if ( geo.match( /^\d+$/ ) ) {
 
-        var mesh = null;
-        if ( geo.bones === undefined || geo.skins === undefined || this.animations === undefined || this.animations.length === 0 ){
+				geoCount ++;
 
-            mesh = new THREE.Mesh( geometry, material );
+			}
 
-        } else {
+		}
 
-            material.skinning = true;
-            mesh = new THREE.SkinnedMesh( geometry, material );
-            this.addAnimation( mesh, this.weights.matrices, this.animations );
+		var res = [];
+		if ( geoCount > 0 ) {
 
-        }
+			for ( geo in node.Objects.subNodes.Geometry ) {
 
-        return mesh;
+				if ( node.Objects.subNodes.Geometry[ geo ].attrType === 'Mesh' ) {
 
-    };
+					res.push( this.parseGeometry( node.Objects.subNodes.Geometry[ geo ], node ) );
 
-    THREE.FBXLoader.prototype.addAnimation = function ( mesh, matrices, animations ) {
+				}
 
-        var animationdata = { "name": 'animationtest', "fps": 30, "length": animations.length, "hierarchy": [] };
+			}
 
-        for (var i=0; i < mesh.geometry.bones.length; ++i) {
-            var name = mesh.geometry.bones[i].name;
-            name = name.replace( /.*:/, '' );
-            animationdata.hierarchy.push( { parent: mesh.geometry.bones[i].parent, name: name, keys:[] } );
-        }
+		} else {
 
-        var hasCurve = function ( animNode, attr ) {
+			res.push( this.parseGeometry( node.Objects.subNodes.Geometry, node ) );
 
-            if ( animNode === undefined ){ return false; }
+		}
 
-            var attrNode;
-            switch ( attr ) {
-                case 'S':
-                    if( animNode.S === undefined ){ return false; }
-                attrNode = animNode.S;
-                break;
+		return res;
 
-                case 'R':
-                    if( animNode.R === undefined ){ return false; }
-                attrNode = animNode.R;
-                break;
+	};
 
-                case 'T':
-                    if( animNode.T === undefined ){ return false; }
-                attrNode = animNode.T;
-                break;
-            }
+	THREE.FBXLoader.prototype.parseGeometry = function ( node, nodes ) {
 
-            if( attrNode.curves.x === undefined ){ return false; }
-            if( attrNode.curves.y === undefined ){ return false; }
-            if( attrNode.curves.z === undefined ){ return false; }
+		geo = ( new Geometry() ).parse( node );
+		geo.addBones( this.hierarchy.hierarchy );
 
-            return true;
+		//*
+		var geometry = new THREE.BufferGeometry();
+		geometry.name = geo.name;
+		geometry.addAttribute( 'position', new THREE.BufferAttribute( new Float32Array( geo.vertices ), 3 ) );
 
-        };
+		if ( geo.normals !== undefined && geo.normals.length > 0 ) {
 
-        var hasKeyOnFrame = function ( attrNode, frame ) {
-            var x = isKeyExistOnFrame( attrNode.curves.x, frame );
-            var y = isKeyExistOnFrame( attrNode.curves.y, frame );
-            var z = isKeyExistOnFrame( attrNode.curves.z, frame );
+			geometry.addAttribute( 'normal', new THREE.BufferAttribute( new Float32Array( geo.normals ), 3 ) );
 
-            return x && y && z;
-        };
+		}
 
-        var isKeyExistOnFrame = function ( curve, frame ) {
-            var value = curve.values[ frame ];
-            return value !== undefined;
-        };
+		if ( geo.uvs !== undefined && geo.uvs.length > 0 ) {
 
+			geometry.addAttribute( 'uv', new THREE.BufferAttribute( new Float32Array( geo.uvs ), 2 ) );
 
-        var genKey = function ( animNode, bone ) {
+		}
 
-            // key initialize with its bone's bind pose at first
-            var key = {};
-            key.time = frame / animations.fps;  // TODO:
-            key.pos = bone.pos;
-            key.rot = bone.rotq;
-            key.scl = bone.scl;
+		if ( geo.indices !== undefined && geo.indices.length > 65535 ) {
 
-            if ( animNode === undefined ){
-                return key;
-            }
+			geometry.setIndex( new THREE.BufferAttribute( new Uint32Array( geo.indices ), 1 ) );
 
-            try {
-                if ( hasCurve( animNode, 'T' ) && hasKeyOnFrame( animNode.T, frame ) ) {
-                    var pos = new THREE.Vector3(
-                        animNode.T.curves.x.values[ frame ],
-                        animNode.T.curves.y.values[ frame ],
-                        animNode.T.curves.z.values[ frame ] );
-                        key.pos = [ pos.x, pos.y, pos.z ];
-                } else {
-                    delete key.pos;
-                }
+		} else if ( geo.indices !== undefined ) {
 
-                if ( hasCurve( animNode, 'R' ) && hasKeyOnFrame( animNode.R, frame ) ){
-                    var rx  = degToRad( animNode.R.curves.x.values[ frame ] );
-                    var ry  = degToRad( animNode.R.curves.y.values[ frame ] );
-                    var rz  = degToRad( animNode.R.curves.z.values[ frame ] );
-                    var eul = new THREE.Vector3( rx, ry, rz );
-                    var rot = quatFromVec( eul.x, eul.y, eul.z );
-                    key.rot = [ rot.x, rot.y, rot.z, rot.w ];
-                } else {
-                    delete key.rot;
-                }
+			geometry.setIndex( new THREE.BufferAttribute( new Uint16Array( geo.indices ), 1 ) );
 
-                if ( hasCurve( animNode, 'S' ) && hasKeyOnFrame( animNode.S, frame ) ) {
-                    var scl = new THREE.Vector3(
-                        animNode.S.curves.x.values[ frame ],
-                        animNode.S.curves.y.values[ frame ],
-                        animNode.S.curves.z.values[ frame ]  );
-                        key.scl = [ scl.x, scl.y, scl.z ];
-                } else {
-                    delete key.scl;
-                }
+		}
 
-            } catch ( e ){
-                // curve is not full plotted
-                console.log( bone );
-                console.log( e );
-            }
+		geometry.verticesNeedUpdate = true;
+		geometry.computeBoundingSphere();
+		geometry.computeBoundingBox();
 
-            return key;
+		// TODO: texture & material support
+		var texture;
+		var texs = this.textures.getById( nodes.searchConnectionParent( geo.id ) );
+		if ( texs !== undefined && texs.length > 0 ) {
 
-        };
+			if ( this.textureLoader === null ) {
 
-        var bones = mesh.geometry.bones;
-        for ( frame = 0; frame < animations.frames; frame ++ ) {
+				this.textureLoader = new THREE.TextureLoader();
 
+			}
+			texture = this.textureLoader.load( this.textureBasePath + '/' + texs[ 0 ].fileName );
 
-            for ( i=0; i < bones.length; i ++ ) {
-                var bone = bones[ i ];
-                var animNode = animations.curves[ i ];
+		}
 
-                for ( var j = 0; j < animationdata.hierarchy.length; j ++ ) {
+		var material;
+		if ( texture !== undefined ) {
 
-                    if ( animationdata.hierarchy[ j ].name === bone.name ) {
-                        animationdata.hierarchy[ j ].keys.push( genKey( animNode, bone ) );
-                    }
-                }
-            }
-        }
+			material = new THREE.MeshBasicMaterial( { map: texture } );
 
-        if ( mesh.geometry.animations === undefined ) {
+		} else {
 
-            mesh.geometry.animations = [];
+			material = new THREE.MeshBasicMaterial( { color: 0x3300ff } );
 
-        }
+		}
 
-        mesh.geometry.animations.push( THREE.AnimationClip.parseAnimation( animationdata, mesh.geometry.bones ) );
+		geometry = new THREE.Geometry().fromBufferGeometry( geometry );
+		geometry.bones = geo.bones;
+		geometry.skinIndices = this.weights.skinIndices;
+		geometry.skinWeights = this.weights.skinWeights;
 
-    };
+		var mesh = null;
+		if ( geo.bones === undefined || geo.skins === undefined || this.animations === undefined || this.animations.length === 0 ) {
 
-    /* ----------------------------------------------------------------- */
-    THREE.FBXLoader.prototype.parseMaterials = function ( node ) {
+			mesh = new THREE.Mesh( geometry, material );
 
-        // has not mat, return []
-        if ( !( 'Material' in node.subNodes ) ) { return []; }
+		} else {
 
-        // has many
-        var matCount = 0;
-        for ( var mat in node.subNodes.Materials ) {
-            if ( mat.match( /^\d+$/ )){ matCount++; }
-        }
+			material.skinning = true;
+			mesh = new THREE.SkinnedMesh( geometry, material );
+			this.addAnimation( mesh, this.weights.matrices, this.animations );
 
-        var res = [];
-        if ( matCount > 0 ){
+		}
 
-            for ( mat in node.subNodes.Material ) {
-                res.push( parseMaterial( node.subNodes.Material[mat] ) );
-            }
+		return mesh;
 
-        } else {
+	};
 
-            res.push( parseMaterial( node.subNodes.Material ) );
+	THREE.FBXLoader.prototype.addAnimation = function ( mesh, matrices, animations ) {
 
-        }
+		var animationdata = { "name": 'animationtest', "fps": 30, "length": animations.length, "hierarchy": [] };
 
-        return res;
+		for ( var i = 0; i < mesh.geometry.bones.length; ++ i ) {
 
-    };
+			var name = mesh.geometry.bones[ i ].name;
+			name = name.replace( /.*:/, '' );
+			animationdata.hierarchy.push( { parent: mesh.geometry.bones[ i ].parent, name: name, keys: [] } );
 
-    // TODO
-    THREE.FBXLoader.prototype.parseMaterial = function ( node ) {
+		}
 
-    };
+		var hasCurve = function ( animNode, attr ) {
 
+			if ( animNode === undefined ) {
 
-    THREE.FBXLoader.prototype.loadFile = function ( url, onLoad, onProgress, onError, responseType ) {
+				return false;
 
-        var loader = new THREE.XHRLoader( this.manager );
+			}
 
-        loader.setResponseType( responseType );
+			var attrNode;
+			switch ( attr ) {
 
-        var request = loader.load( url, function ( result ) {
+				case 'S':
+					if ( animNode.S === undefined ) {
 
-            onLoad( result );
+						return false;
 
-        }, onProgress, onError );
+					}
+					attrNode = animNode.S;
+					break;
 
-        return request;
+				case 'R':
+					if ( animNode.R === undefined ) {
 
-    };
+						return false;
 
-    THREE.FBXLoader.prototype.loadFileAsBuffer = function ( url, onload, onProgress, onError ) {
+					}
+					attrNode = animNode.R;
+					break;
 
-        this.loadFile( url, onLoad, onProgress, onError, 'arraybuffer' );
+				case 'T':
+					if ( animNode.T === undefined ) {
 
-    };
+						return false;
 
-    THREE.FBXLoader.prototype.loadFileAsText = function ( url, onLoad, onProgress, onError ) {
+					}
+					attrNode = animNode.T;
+					break;
+			}
 
-        this.loadFile( url, onLoad, onProgress, onError, 'text' );
+			if ( attrNode.curves.x === undefined ) {
 
-    };
+				return false;
 
+			}
 
+			if ( attrNode.curves.y === undefined ) {
 
+				return false;
 
-    function FBXNodes() {}
+			}
 
-    FBXNodes.prototype.add = function ( key, val ) {
-        this[ key ] =  val;
-    };
+			if ( attrNode.curves.z === undefined ) {
 
-    FBXNodes.prototype.searchConnectionParent = function ( id ) {
+				return false;
 
-        if ( this.__cache_search_connection_parent === undefined ){
-            this.__cache_search_connection_parent = [];
-        }
-        
-        if ( this.__cache_search_connection_parent[ id ] !== undefined ){
-            return this.__cache_search_connection_parent[ id ];
-        } else {
-            this.__cache_search_connection_parent[ id ] = [];
-        }
+			}
 
-        var conns   = this.Connections.properties.connections;
+			return true;
 
-        var results = [];
-        for (var i=0; i < conns.length; ++i) {
+		};
 
-            if ( conns[i][0] == id ) {
-                // 0 means scene root
-                var res = conns[i][1] === 0 ? -1 : conns[i][1];
-                results.push( res );
+		var hasKeyOnFrame = function ( attrNode, frame ) {
 
-            }
+			var x = isKeyExistOnFrame( attrNode.curves.x, frame );
+			var y = isKeyExistOnFrame( attrNode.curves.y, frame );
+			var z = isKeyExistOnFrame( attrNode.curves.z, frame );
 
-        }
+			return x && y && z;
 
-        if ( results.length > 0 ){
-            this.__cache_search_connection_parent[ id ] = this.__cache_search_connection_parent[ id ].concat( results );
-            return results;
+		};
 
-        } else {
+		var isKeyExistOnFrame = function ( curve, frame ) {
 
-            this.__cache_search_connection_parent[ id ] = [-1];
-            return [-1];
-        }
+			var value = curve.values[ frame ];
+			return value !== undefined;
 
-    };
+		};
 
-    FBXNodes.prototype.searchConnectionChildren = function ( id ) {
-        if ( this.__cache_search_connection_children === undefined ){
-            this.__cache_search_connection_children = [];
-        }
 
-        if ( this.__cache_search_connection_children[ id ] !== undefined ){
-            return this.__cache_search_connection_children[ id ];
-        } else {
-            this.__cache_search_connection_children[ id ] = [];
-        }
+		var genKey = function ( animNode, bone ) {
 
-        var conns   = this.Connections.properties.connections;
+			// key initialize with its bone's bind pose at first
+			var key = {};
+			key.time = frame / animations.fps; // TODO:
+			key.pos = bone.pos;
+			key.rot = bone.rotq;
+			key.scl = bone.scl;
 
-        var res = [];
-        for (var i=0; i < conns.length; ++i) {
+			if ( animNode === undefined ) {
 
-            if ( conns[i][1] == id ) {
-                // 0 means scene root
-                res.push( conns[i][0] === 0 ? -1 : conns[i][0] );
-                // there may more than one kid, then search to the end
-            }
+				return key;
 
-        }
+			}
 
-        if ( res.length > 0 ){
-            this.__cache_search_connection_children[ id ] = this.__cache_search_connection_children[ id ].concat( res );
-            return res;
+			try {
 
-        } else {
+				if ( hasCurve( animNode, 'T' ) && hasKeyOnFrame( animNode.T, frame ) ) {
 
-            this.__cache_search_connection_children[ id ] = [-1];
-            return [-1];
-        }
+					var pos = new THREE.Vector3(
+						animNode.T.curves.x.values[ frame ],
+						animNode.T.curves.y.values[ frame ],
+						animNode.T.curves.z.values[ frame ] );
+					key.pos = [ pos.x, pos.y, pos.z ];
 
-    };
+				} else {
 
-    FBXNodes.prototype.searchConnectionType = function ( id, to ) {
-        var key = id + ',' + to;  // TODO: to hash
-        if ( this.__cache_search_connection_type === undefined ){
-            this.__cache_search_connection_type = '';
-        }
+					delete key.pos;
 
-        if ( this.__cache_search_connection_type[ key ] !== undefined ){
-            return this.__cache_search_connection_type[ key ];
-        } else {
-            this.__cache_search_connection_type[ key ] = '';
-        }
+				}
 
-        var conns   = this.Connections.properties.connections;
+				if ( hasCurve( animNode, 'R' ) && hasKeyOnFrame( animNode.R, frame ) ) {
 
-        for (var i=0; i < conns.length; ++i) {
+					var rx = degToRad( animNode.R.curves.x.values[ frame ] );
+					var ry = degToRad( animNode.R.curves.y.values[ frame ] );
+					var rz = degToRad( animNode.R.curves.z.values[ frame ] );
+					var eul = new THREE.Vector3( rx, ry, rz );
+					var rot = quatFromVec( eul.x, eul.y, eul.z );
+					key.rot = [ rot.x, rot.y, rot.z, rot.w ];
 
-            if ( conns[i][0] == id && conns[i][1] == to ) {
-                // 0 means scene root
-                this.__cache_search_connection_type[ key ] = conns[i][2];
-                return conns[i][2];
-            }
+				} else {
 
-        }
+					delete key.rot;
 
-        this.__cache_search_connection_type[ id ] = null;
-        return null;
+				}
 
-    };
+				if ( hasCurve( animNode, 'S' ) && hasKeyOnFrame( animNode.S, frame ) ) {
 
-    function FBXParser() {}
+					var scl = new THREE.Vector3(
+						animNode.S.curves.x.values[ frame ],
+						animNode.S.curves.y.values[ frame ],
+						animNode.S.curves.z.values[ frame ] );
+					key.scl = [ scl.x, scl.y, scl.z ];
 
-    FBXParser.prototype = {
+				} else {
 
-        // constructor: FBXParser,
+					delete key.scl;
 
-        // ------------ node stack manipulations ----------------------------------
+				}
 
-        getPrevNode: function () {
-            return this.nodeStack[ this.currentIndent - 2 ];
-        },
+			} catch ( e ) {
 
-        getCurrentNode: function () {
-            return this.nodeStack[ this.currentIndent - 1 ];
-        },
+				// curve is not full plotted
+				console.log( bone );
+				console.log( e );
 
-        getCurrentProp: function () {
-            return this.currentProp;
-        },
+			}
 
-        pushStack: function( node ) {
+			return key;
 
-            this.nodeStack.push( node );
-            this.currentIndent += 1;
+		};
 
-        },
+		var bones = mesh.geometry.bones;
+		for ( frame = 0; frame < animations.frames; frame ++ ) {
 
-        popStack: function() {
 
-            this.nodeStack.pop();
-            this.currentIndent -= 1;
+			for ( i = 0; i < bones.length; i ++ ) {
 
-        },
+				var bone = bones[ i ];
+				var animNode = animations.curves[ i ];
 
-        setCurrentProp: function ( val, name ){
+				for ( var j = 0; j < animationdata.hierarchy.length; j ++ ) {
 
-            this.currentProp = val;
-            this.currentPropName = name;
+					if ( animationdata.hierarchy[ j ].name === bone.name ) {
 
-        },
+						animationdata.hierarchy[ j ].keys.push( genKey( animNode, bone ) );
 
-        // ----------parse ---------------------------------------------------
-        parse: function ( text ) {
+					}
 
-            console.time( 'FBXLoader: total' );
+				}
 
-            this.currentIndent = 0;
-            this.allNodes = new FBXNodes();
-            this.nodeStack = [];
-            this.currentProp = [];
-            this.currentPropName = '';
+			}
 
-            console.time( 'FBXLoader: TextParser' );
+		}
 
-            var split = text.split( "\n" );
-            for ( var line in split ) {
+		if ( mesh.geometry.animations === undefined ) {
 
-                var l = split[line];
+			mesh.geometry.animations = [];
 
-                // short cut
-                if ( l.match( /^[\s\t]*;/ ) ){ continue; }  // skip comment line
-                if ( l.match( /^[\s\t]*$/ ) ){ continue; }  // skip empty line
+		}
 
-                // beginning of node
-                var beginningOfNodeExp   = new RegExp( "^\\t{" + this.currentIndent + "}(\\w+):(.*){", '' );
-                match = l.match( beginningOfNodeExp );
-                if ( match ){
+		mesh.geometry.animations.push( THREE.AnimationClip.parseAnimation( animationdata, mesh.geometry.bones ) );
 
-                    var nodeName  = match[1].trim().replace( /^"/, '' ).replace( /"$/, "" );
-                    var nodeAttrs = match[2].split( ',' ).map( function ( element ) {
-                        return element.trim().replace( /^"/, '' ).replace( /"$/, '' );
-                    });
+	};
 
-                    this.parseNodeBegin( l, nodeName, nodeAttrs || null );
-                    continue;
+	THREE.FBXLoader.prototype.parseMaterials = function ( node ) {
 
-                }
+		// has not mat, return []
+		if ( ! ( 'Material' in node.subNodes ) ) {
 
-                // node's property
-                var propExp = new RegExp( "^\\t{" + ( this.currentIndent )+ "}(\\w+):[\\s\\t\\r\\n](.*)" );
-                match = l.match( propExp );
-                if ( match ){
+			return [];
 
-                    var propName  = match[1].replace( /^"/, '' ).replace( /"$/, "" ).trim();
-                    var propValue = match[2].replace( /^"/, '' ).replace( /"$/, "" ).trim();
+		}
 
-                    this.parseNodeProperty( l, propName, propValue );
-                    continue;
+		// has many
+		var matCount = 0;
+		for ( var mat in node.subNodes.Materials ) {
 
-                }
+			if ( mat.match( /^\d+$/ ) ) {
 
-                // end of node
-                var endOfNodeExp = new RegExp( "^\\t{" + ( this.currentIndent - 1 ) + "}}" );
-                if ( l.match( endOfNodeExp ) ){
+				matCount ++;
 
-                    this.nodeEnd();
-                    continue;
+			}
 
-                }
+		}
 
-                // for special case,
-                //
-                //      Vertices: *8670 {
-                //          a: 0.0356229953467846,13.9599733352661,-0.399196773.....(snip)
-                // -0.0612030513584614,13.960485458374,-0.409748703241348,-0.10.....
-                // 0.12490539252758,13.7450733184814,-0.454119384288788,0.09272.....
-                // 0.0836158767342567,13.5432004928589,-0.435397416353226,0.028.....
-                //
-                // these case the lines must contiue with previous line
-                if ( l.match( /^[^\s\t}]/ ) ) {
+		var res = [];
+		if ( matCount > 0 ) {
 
-                    this.parseNodePropertyContinued( l );
+			for ( mat in node.subNodes.Material ) {
 
-                }
-            }
+				res.push( parseMaterial( node.subNodes.Material[ mat ] ) );
 
-            console.timeEnd( 'FBXLoader: TextParser' );
-            return this.allNodes;
+			}
 
+		} else {
 
-        },
+			res.push( parseMaterial( node.subNodes.Material ) );
 
-        parseNodeBegin: function ( line, nodeName, nodeAttrs ) {
+		}
 
-            // var nodeName = match[1];
-            var node = { 'name': nodeName, properties: {}, 'subNodes': {} };
-            var attrs = this.parseNodeAttr( nodeAttrs );
-            var currentNode = this.getCurrentNode();
+		return res;
 
-            // a top node
-            if ( this.currentIndent === 0 ){
+	};
 
-                this.allNodes.add( nodeName, node );
+	// TODO
+	THREE.FBXLoader.prototype.parseMaterial = function ( node ) {
 
-            } else {  // a subnode
+	};
 
-                // already exists subnode, then append it
-                if ( nodeName in currentNode.subNodes ){
 
-                    var tmp = currentNode.subNodes[ nodeName ];
+	THREE.FBXLoader.prototype.loadFile = function ( url, onLoad, onProgress, onError, responseType ) {
 
-                    // console.log( "duped entry found\nkey: " + nodeName + "\nvalue: " + propValue );
-                    if ( this.isFlattenNode( currentNode.subNodes[ nodeName ] ) ) {
+		var loader = new THREE.XHRLoader( this.manager );
 
+		loader.setResponseType( responseType );
 
-                        if ( attrs.id === '' ){
-                            currentNode.subNodes[ nodeName ] = [];
-                            currentNode.subNodes[ nodeName ].push( tmp );
-                        } else {
-                            currentNode.subNodes[ nodeName ] = {};
-                            currentNode.subNodes[ nodeName ][ tmp.id ] = tmp;
-                        }
+		var request = loader.load( url, function ( result ) {
 
-                    }
+			onLoad( result );
 
-                    if ( attrs.id === '' ){
-                        currentNode.subNodes[ nodeName ].push( node );
-                    } else {
-                        currentNode.subNodes[ nodeName ][ attrs.id ] = node;
-                    }
+		}, onProgress, onError );
 
-                } else {
+		return request;
 
-                    currentNode.subNodes[ nodeName ] =  node;
+	};
 
-                }
+	THREE.FBXLoader.prototype.loadFileAsBuffer = function ( url, onload, onProgress, onError ) {
 
-            }
+		this.loadFile( url, onLoad, onProgress, onError, 'arraybuffer' );
 
-            // for this          ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
-            // NodeAttribute: 1001463072, "NodeAttribute::", "LimbNode" {
-            if ( nodeAttrs ) {
+	};
 
-                node.id       = attrs.id;
-                node.attrName = attrs.name;
-                node.attrType = attrs.type;
+	THREE.FBXLoader.prototype.loadFileAsText = function ( url, onLoad, onProgress, onError ) {
 
-            }
+		this.loadFile( url, onLoad, onProgress, onError, 'text' );
 
-            this.pushStack( node );
+	};
 
-        },
 
-        parseNodeAttr: function ( attrs ) {
+	/* ----------------------------------------------------------------- */
 
-            var id = attrs[0];
+	function FBXNodes() {}
 
-            if ( attrs[0] !== "" ) {
+	FBXNodes.prototype.add = function ( key, val ) {
 
-                id = parseInt( attrs[0] );
+		this[ key ] = val;
 
-                if ( isNaN( id) ){
+	};
 
-                    // PolygonVertexIndex: *16380 {
-                    id = attrs[0];
-                }
+	FBXNodes.prototype.searchConnectionParent = function ( id ) {
 
-            }
+		if ( this.__cache_search_connection_parent === undefined ) {
 
-            var name;
-            var type;
-            if ( attrs.length > 1 ){
+			this.__cache_search_connection_parent = [];
 
-                name = attrs[1].replace( /^(\w+)::/, '' );
-                type = attrs[2];
+		}
 
-            }
+		if ( this.__cache_search_connection_parent[ id ] !== undefined ) {
 
-            return { id:id, name:name || '', type:type || '' };
+			return this.__cache_search_connection_parent[ id ];
 
-        },
+		} else {
 
-        parseNodeProperty: function ( line, propName, propValue ){
+			this.__cache_search_connection_parent[ id ] = [];
 
-            var currentNode   = this.getCurrentNode();
-            var parentName = currentNode.name;
+		}
 
-            // special case parent node's is like "Properties70"
-            // these chilren nodes must treat with careful
-            if ( parentName !== undefined ){
+		var conns = this.Connections.properties.connections;
 
-                var propMatch = parentName.match( /Properties(\d)+/ );
-                if ( propMatch ) {
-                    this.parseNodeSpecialProperty( line, propName, propValue );
-                    return;
-                }
-            }
+		var results = [];
+		for ( var i = 0; i < conns.length; ++ i ) {
 
-            // special case Connections
-            if (  propName == 'C' ){
+			if ( conns[ i ][ 0 ] == id ) {
 
-                var connProps = propValue.split( ',' ).slice( 1 );
-                var from = parseInt( connProps[0] );
-                var to   = parseInt( connProps[1] );
+				// 0 means scene root
+				var res = conns[ i ][ 1 ] === 0 ? - 1 : conns[ i ][ 1 ];
+				results.push( res );
 
-                var rest = propValue.split( ',' ).slice( 3 );
+			}
 
-                propName  = 'connections';
-                propValue = [ from, to ];
-                propValue = propValue.concat( rest );
+		}
 
-                if ( currentNode.properties[ propName ] === undefined ){
-                    currentNode.properties[ propName ] = [];
-                }
+		if ( results.length > 0 ) {
 
-            }
+			this.__cache_search_connection_parent[ id ] = this.__cache_search_connection_parent[ id ].concat( results );
+			return results;
 
-            // special case Connections
-            if (  propName == 'Node' ){
+		} else {
 
-                var id = parseInt( propValue );
-                currentNode.properties.id = id;
-                currentNode.id = id;
+			this.__cache_search_connection_parent[ id ] = [ - 1 ];
+			return [ - 1 ];
 
-            }
+		}
 
-            // already exists in properties, then append this
-            if ( propName in currentNode.properties ){
+	};
 
-                // console.log( "duped entry found\nkey: " + propName + "\nvalue: " + propValue );
-                if ( Array.isArray( currentNode.properties[ propName ] ) ){
+	FBXNodes.prototype.searchConnectionChildren = function ( id ) {
 
-                    currentNode.properties[ propName ].push( propValue );
+		if ( this.__cache_search_connection_children === undefined ) {
 
-                } else {
+			this.__cache_search_connection_children = [];
 
-                    currentNode.properties[ propName ] += propValue;
+		}
 
-                }
+		if ( this.__cache_search_connection_children[ id ] !== undefined ) {
 
-            } else {
+			return this.__cache_search_connection_children[ id ];
 
-                // console.log( propName + ":  " + propValue );
-                if ( Array.isArray( currentNode.properties[ propName ] ) ){
+		} else {
 
-                    currentNode.properties[ propName ].push( propValue );
+			this.__cache_search_connection_children[ id ] = [];
 
-                } else {
+		}
 
-                    currentNode.properties[ propName ] = propValue;
+		var conns = this.Connections.properties.connections;
 
-                }
+		var res = [];
+		for ( var i = 0; i < conns.length; ++ i ) {
 
-            }
+			if ( conns[ i ][ 1 ] == id ) {
 
-            this.setCurrentProp( currentNode.properties, propName );
+				// 0 means scene root
+				res.push( conns[ i ][ 0 ] === 0 ? - 1 : conns[ i ][ 0 ] );
+				// there may more than one kid, then search to the end
 
-        },
+			}
 
-        // TODO:
-        parseNodePropertyContinued: function ( line ) {
+		}
 
-            this.currentProp[ this.currentPropName ] += line;
+		if ( res.length > 0 ) {
 
-        },
+			this.__cache_search_connection_children[ id ] = this.__cache_search_connection_children[ id ].concat( res );
+			return res;
 
-        parseNodeSpecialProperty: function ( line, propName, propValue ) {
+		} else {
 
-            // split this
-            // P: "Lcl Scaling", "Lcl Scaling", "", "A",1,1,1
-            // into array like below
-            // ["Lcl Scaling", "Lcl Scaling", "", "A", "1,1,1" ]
-            var props = propValue.split( '",' ).map( function( element ) {
+			this.__cache_search_connection_children[ id ] = [ - 1 ];
+			return [ - 1 ];
 
-                return element.trim().replace( /^\"/, '' ).replace( /\s/, '_' );
+		}
 
-            });
+	};
 
-            var innerPropName  = props[0];
-            var innerPropType1 = props[1];
-            var innerPropType2 = props[2];
-            var innerPropFlag  = props[3];
-            var innerPropValue = props[4];
+	FBXNodes.prototype.searchConnectionType = function ( id, to ) {
 
-            /*
-            if ( innerPropValue === undefined ){
-                innerPropValue = props[3];
-            }
-            */
+		var key = id + ',' + to; // TODO: to hash
+		if ( this.__cache_search_connection_type === undefined ) {
 
-            // cast value in its type
-            switch ( innerPropType1 ) {
+			this.__cache_search_connection_type = '';
 
-                case "int":
-                    innerPropValue = parseInt( innerPropValue );
-                    break;
+		}
 
-                case "double":
-                    innerPropValue = parseFloat( innerPropValue );
-                    break;
+		if ( this.__cache_search_connection_type[ key ] !== undefined ) {
 
-                case "ColorRGB":
-                case "Vector3D":
-                    var tmp = innerPropValue.split( ',' );
-                    innerPropValue = new THREE.Vector3( tmp[0], tmp[1], tmp[2] );
-                    break;
+			return this.__cache_search_connection_type[ key ];
 
-            }
+		} else {
 
-            // CAUTION: these props must append to parent's parent
-            this.getPrevNode().properties[ innerPropName ] = {
+			this.__cache_search_connection_type[ key ] = '';
 
-                'type':  innerPropType1,
-                'type2': innerPropType2,
-                'flag':  innerPropFlag,
-                'value': innerPropValue
+		}
 
-            };
+		var conns = this.Connections.properties.connections;
 
-            this.setCurrentProp(  this.getPrevNode().properties,  innerPropName );
+		for ( var i = 0; i < conns.length; ++ i ) {
 
-        },
+			if ( conns[ i ][ 0 ] == id && conns[ i ][ 1 ] == to ) {
 
-        nodeEnd: function ( line ) {
+				// 0 means scene root
+				this.__cache_search_connection_type[ key ] = conns[ i ][ 2 ];
+				return conns[ i ][ 2 ];
 
-            this.popStack();
+			}
 
-        },
+		}
 
-        /* ---------------------------------------------------------------- */
-        /*        util                                                      */
-        isFlattenNode: function ( node ) {
+		this.__cache_search_connection_type[ id ] = null;
+		return null;
 
-            return ( 'subNodes' in node && 'properties' in node ) ? true : false;
+	};
 
-        }
+	function FBXParser() {}
 
-    };
+	FBXParser.prototype = {
 
-    function FBXAnalyzer() {}
+		// constructor: FBXParser,
 
-    FBXAnalyzer.prototype = {
+		// ------------ node stack manipulations ----------------------------------
 
-    };
+		getPrevNode: function () {
 
+			return this.nodeStack[ this.currentIndent - 2 ];
 
-    // generate skinIndices, skinWeights
-    //      @skinIndices: per vertex data, this represents the bone indexes affects that vertex
-    //      @skinWeights: per vertex data, this represents the Weight Values affects that vertex
-    //      @matrices:    per `bones` data
-    function Weights () {
+		},
 
-        this.skinIndices = [];
-        this.skinWeights = [];
+		getCurrentNode: function () {
 
-        this.matrices    = [];
-    }
+			return this.nodeStack[ this.currentIndent - 1 ];
 
-    
-    Weights.prototype.parseCluster = function ( node, id, entry ){
+		},
 
-        var _p         = node.searchConnectionParent( id );
-        var _indices   = toInt( entry.subNodes.Indexes.properties.a.split( ',' ) );
-        var _weights   = toFloat( entry.subNodes.Weights.properties.a.split( ',' ) );
-        var _transform = toMat44( toFloat( entry.subNodes.Transform.properties.a.split( ',' ) ) );
-        var _link      = toMat44( toFloat( entry.subNodes.TransformLink.properties.a.split( ',' ) ));
+		getCurrentProp: function () {
 
-        return {
+			return this.currentProp;
 
-            'parent':        _p,
-            'id':            parseInt( id ),
-            'indices':       _indices,
-            'weights':       _weights,
-            'transform':     _transform,
-            'transformlink': _link,
-            'linkMode':      entry.properties.Mode
+		},
 
-        };
+		pushStack: function ( node ) {
 
-    };
+			this.nodeStack.push( node );
+			this.currentIndent += 1;
 
-    Weights.prototype.parse = function ( node, bones ){
+		},
 
-        this.skinIndices = [];
-        this.skinWeights = [];
+		popStack: function () {
 
-        this.matrices = [];
+			this.nodeStack.pop();
+			this.currentIndent -= 1;
 
-        var deformers = node.Objects.subNodes.Deformer;
+		},
 
-        var clusters  = {};
-        for ( var id in deformers ) {
-            if ( deformers[id].attrType === 'Cluster' ){
+		setCurrentProp: function ( val, name ) {
 
-                if ( !( 'Indexes' in deformers[id].subNodes )){ continue; }
+			this.currentProp = val;
+			this.currentPropName = name;
 
-                //clusters.push( this.parseCluster( node, id, deformers[id] ) );
-                var cluster =  this.parseCluster( node, id, deformers[id] );
-                var boneId = node.searchConnectionChildren( cluster.id )[ 0 ];
-                clusters[ boneId ] = cluster;
+		},
 
-            }
-        }
+		// ----------parse ---------------------------------------------------
+		parse: function ( text ) {
 
+			console.time( 'FBXLoader: total' );
 
-        // this clusters is per Bone data, thus we make this into per vertex data
-        var weights = [];
-        var hi = bones.hierarchy;
-        for (var b=0; b < hi.length; ++b) {
+			this.currentIndent = 0;
+			this.allNodes = new FBXNodes();
+			this.nodeStack = [];
+			this.currentProp = [];
+			this.currentPropName = '';
 
-            var bid = hi[ b ].internalId;
-            if ( clusters[ bid ] === undefined ){
-                //console.log( bid );
-                this.matrices.push( new THREE.Matrix4() );
-                continue;
-            }
+			console.time( 'FBXLoader: TextParser' );
 
-            var clst = clusters[ bid ];
-            // store transform matrix per bones
-            this.matrices.push( clst.transform );
-            //this.matrices.push( clst.transformlink );
-            for ( var v=0; v < clst.indices.length; ++v ){
+			var split = text.split( "\n" );
+			for ( var line in split ) {
 
-                if ( weights[ clst.indices[v] ] === undefined ){
+				var l = split[ line ];
 
-                    weights[ clst.indices[v] ] = {};
-                    weights[ clst.indices[v] ].joint  = [];
-                    weights[ clst.indices[v] ].weight = [];
+				// short cut
+				if ( l.match( /^[\s\t]*;/ ) ) {
 
-                }
+					continue;
 
-                // indices
-                var affect = node.searchConnectionChildren( clst.id );
+				} // skip comment line
+				if ( l.match( /^[\s\t]*$/ ) ) {
 
-                if ( affect.length > 1 ){
-                    console.warn( "FBXLoader: node " + clst.id + " have many weight kids: " + affect );
-                }
-                weights[ clst.indices[v] ].joint.push( bones.getBoneIdfromInternalId( node, affect[0] ) );
+					continue;
 
-                // weight value
-                weights[ clst.indices[v] ].weight.push( clst.weights[v] );
+				} // skip empty line
 
-            }
-
-        }
-
-        // normalize the skin weights
-        // TODO -  this might be a good place to choose greatest 4 weights
-        for ( var i = 0; i < weights.length; i ++ ) {
-
-            var indicies = new THREE.Vector4(
-                weights[ i ].joint[ 0 ] ? weights[ i ].joint[ 0 ] : 0,
-                weights[ i ].joint[ 1 ] ? weights[ i ].joint[ 1 ] : 0,
-                weights[ i ].joint[ 2 ] ? weights[ i ].joint[ 2 ] : 0,
-                weights[ i ].joint[ 3 ] ? weights[ i ].joint[ 3 ] : 0 );
-
-            var weight = new THREE.Vector4(
-                weights[ i ].weight[ 0 ] ? weights[ i ].weight[ 0 ] : 0,
-                weights[ i ].weight[ 1 ] ? weights[ i ].weight[ 1 ] : 0,
-                weights[ i ].weight[ 2 ] ? weights[ i ].weight[ 2 ] : 0,
-                weights[ i ].weight[ 3 ] ? weights[ i ].weight[ 3 ] : 0 );
-
-            this.skinIndices.push( indicies );
-            this.skinWeights.push( weight );
-
-        }
-
-        //console.log( this );
-        return this;
-
-    };
-
-    function Bones() {
-
-            // returns bones hierarchy tree.
-            //      [
-            //          {
-            //              "parent": id,
-            //              "name": name,
-            //              "pos": pos,
-            //              "rotq": quat
-            //          },
-            //          ...
-            //          {},
-            //          ...
-            //      ]
-            //
-            /* sample response
-
-               "bones" : [
-                {"parent":-1, "name":"Fbx01",            "pos":[-0.002,     98.739,   1.6e-05],     "rotq":[0, 0, 0, 1]},
-                {"parent":0,  "name":"Fbx01_Pelvis",     "pos":[0.00015963, 0,        7.33107e-08], "rotq":[0, 0, 0, 1]},
-                {"parent":1,  "name":"Fbx01_Spine",      "pos":[6.577e-06,  10.216,   0.0106811],   "rotq":[0, 0, 0, 1]},
-                {"parent":2,  "name":"Fbx01_R_Thigh",    "pos":[14.6537,    -10.216,  -0.00918758], "rotq":[0, 0, 0, 1]},
-                {"parent":3,  "name":"Fbx01_R_Calf",     "pos":[-3.70047,     -42.9681,     -7.78158],     "rotq":[0, 0, 0, 1]},
-                {"parent":4,  "name":"Fbx01_R_Foot",     "pos":[-2.0696,      -46.0488,     9.42052],      "rotq":[0, 0, 0, 1]},
-                {"parent":5,  "name":"Fbx01_R_Toe0",     "pos":[-0.0234785,   -9.46233,     -15.3187],     "rotq":[0, 0, 0, 1]},
-                {"parent":2,  "name":"Fbx01_L_Thigh",    "pos":[-14.6537,     -10.216,      -0.00918314],  "rotq":[0, 0, 0, 1]},
-                {"parent":7,  "name":"Fbx01_L_Calf",     "pos":[3.70037,      -42.968,      -7.78155],     "rotq":[0, 0, 0, 1]},
-                {"parent":8,  "name":"Fbx01_L_Foot",     "pos":[2.06954,      -46.0488,     9.42052],      "rotq":[0, 0, 0, 1]},
-                {"parent":9,  "name":"Fbx01_L_Toe0",     "pos":[0.0234566,    -9.46235,     -15.3187],     "rotq":[0, 0, 0, 1]},
-                {"parent":2,  "name":"Fbx01_Spine1",     "pos":[-2.97523e-05, 11.5892,      -9.81027e-05], "rotq":[0, 0, 0, 1]},
-                {"parent":11, "name":"Fbx01_Spine2",     "pos":[-2.91292e-05, 11.4685,      8.27126e-05],  "rotq":[0, 0, 0, 1]},
-                {"parent":12, "name":"Fbx01_Spine3",     "pos":[-4.48857e-05, 11.5783,      8.35108e-05],  "rotq":[0, 0, 0, 1]},
-                {"parent":13, "name":"Fbx01_Neck",       "pos":[1.22987e-05,  11.5582,      -0.0044775],   "rotq":[0, 0, 0, 1]},
-                {"parent":14, "name":"Fbx01_Head",       "pos":[-3.50709e-05, 6.62915,      -0.00523254],  "rotq":[0, 0, 0, 1]},
-                {"parent":15, "name":"Fbx01_R_Eye",      "pos":[3.31681,      12.739,       -10.5267],     "rotq":[0, 0, 0, 1]},
-                {"parent":15, "name":"Fbx01_L_Eye",      "pos":[-3.32038,     12.7391,      -10.5267],     "rotq":[0, 0, 0, 1]},
-                {"parent":15, "name":"Jaw",              "pos":[-0.0017738,   7.43481,      -4.08114],     "rotq":[0, 0, 0, 1]},
-                {"parent":14, "name":"Fbx01_R_Clavicle", "pos":[3.10919,      2.46577,      -0.0115284],   "rotq":[0, 0, 0, 1]},
-                {"parent":19, "name":"Fbx01_R_UpperArm", "pos":[16.014,       4.57764e-05,  3.10405],      "rotq":[0, 0, 0, 1]},
-                {"parent":20, "name":"Fbx01_R_Forearm",  "pos":[22.7068,      -1.66322,     -2.13803],     "rotq":[0, 0, 0, 1]},
-                {"parent":21, "name":"Fbx01_R_Hand",     "pos":[25.5881,      -0.80249,     -6.37307],     "rotq":[0, 0, 0, 1]},
-                ...
-                {"parent":27, "name":"Fbx01_R_Finger32", "pos":[2.15572,      -0.548737,    -0.539604],    "rotq":[0, 0, 0, 1]},
-                {"parent":22, "name":"Fbx01_R_Finger2",  "pos":[9.79318,      0.132553,     -2.97845],     "rotq":[0, 0, 0, 1]},
-                {"parent":29, "name":"Fbx01_R_Finger21", "pos":[2.74037,      0.0483093,    -0.650531],    "rotq":[0, 0, 0, 1]},
-                {"parent":55, "name":"Fbx01_L_Finger02", "pos":[-1.65308,     -1.43208,     -1.82885],     "rotq":[0, 0, 0, 1]}
-                ]
-            */
-        this.hierarchy = [];
-
-    }
-
-    Bones.prototype.parseHierarchy = function ( node ){
-
-        var objects = node.Objects;
-        var models  = objects.subNodes.Model;
-
-        var bones = [];
-        for (var id in models ) {
-
-            if ( models[ id ].attrType === undefined ){ continue; }
-            bones.push( models[ id ] );
-
-        }
-
-        this.hierarchy = [];
-        for (var i=0; i < bones.length; ++i) {
-
-            var bone = bones[i];
-
-            var p = node.searchConnectionParent( bone.id )[0];
-            var t = [ 0.0, 0.0, 0.0 ];
-            var r = [ 0.0, 0.0, 0.0, 1.0 ];
-            var s = [ 1.0, 1.0, 1.0 ];
-
-            if ( 'Lcl_Translation' in bone.properties ){
-                t = toFloat( bone.properties.Lcl_Translation.value.split( ',' ) );
-            }
-
-            if ( 'Lcl_Rotation' in bone.properties ){
-                r = toRad( toFloat( bone.properties.Lcl_Rotation.value.split( ',' ) ));
-                var q = new THREE.Quaternion();
-                q.setFromEuler( new THREE.Euler( r[0], r[1], r[2], 'ZYX' ) );
-                r = [ q.x, q.y, q.z, q.w ];
-            }
-
-            if ( 'Lcl_Scaling' in bone.properties ){
-                s = toFloat( bone.properties.Lcl_Scaling.value.split( ',' ) );
-            }
-
-            // replace unsafe character
-            var name = bone.attrName;
-            name = name.replace( /:/, '' );
-            name = name.replace( /_/, '' );
-            name = name.replace( /-/, '' );
-            this.hierarchy.push( { "parent": p, "name": name, "pos": t, "rotq": r, "scl": s, "internalId": bone.id } );
-        }
-
-        this.reindexParentId();
-
-        this.restoreBindPose( node );
-
-        return this;
-
-    };
-
-    Bones.prototype.reindexParentId = function () {
-
-        for ( var h=0; h < this.hierarchy.length; h++ ){
-            for (var ii=0; ii < this.hierarchy.length; ++ii) {
-                if( this.hierarchy[h].parent == this.hierarchy[ii].internalId ){
-                    this.hierarchy[h].parent = ii;
-                    break;
-                }
-            }
-        }
-
-    };
-
-    Bones.prototype.restoreBindPose = function ( node ) {
-
-        var bindPoseNode =  node.Objects.subNodes.Pose;
-        if( bindPoseNode === undefined ){
-            return;
-        }
-
-        var poseNode = bindPoseNode.subNodes.PoseNode;
-        var localMatrices = {};  // store local matrices, modified later( initialy world space )
-        var worldMatrices = {};  // store world matrices
+				// beginning of node
+				var beginningOfNodeExp = new RegExp( "^\\t{" + this.currentIndent + "}(\\w+):(.*){", '' );
+				match = l.match( beginningOfNodeExp );
+				if ( match ) {
 
-        for (var  i=0;  i < poseNode.length; ++ i) {
-            var rawMatLcl = toMat44( poseNode[ i ].subNodes.Matrix.properties.a.split( ',' )  ); 
-            var rawMatWrd = toMat44( poseNode[ i ].subNodes.Matrix.properties.a.split( ',' )  ); 
+					var nodeName = match[ 1 ].trim().replace( /^"/, '' ).replace( /"$/, "" );
+					var nodeAttrs = match[ 2 ].split( ',' ).map( function ( element ) {
 
-            localMatrices[ poseNode[i].id ] = rawMatLcl;
-            worldMatrices[ poseNode[i].id ] = rawMatWrd;
+						return element.trim().replace( /^"/, '' ).replace( /"$/, '' );
 
-        }
+					} );
 
-        for (var  h=0;  h < this.hierarchy.length; ++ h) {
+					this.parseNodeBegin( l, nodeName, nodeAttrs || null );
+					continue;
 
-            var bone = this.hierarchy[ h ];
-            var inId = bone.internalId;
+				}
 
-            if ( worldMatrices[ inId ] === undefined ){
-                // has no bind pose node, possibly be mesh
-                // console.log( bone );
-                continue;
-            }
+				// node's property
+				var propExp = new RegExp( "^\\t{" + ( this.currentIndent ) + "}(\\w+):[\\s\\t\\r\\n](.*)" );
+				match = l.match( propExp );
+				if ( match ) {
 
-            var t = new THREE.Vector3(0, 0, 0);
-            var r = new THREE.Quaternion();
-            var s = new THREE.Vector3( 1, 1, 1 );
+					var propName = match[ 1 ].replace( /^"/, '' ).replace( /"$/, "" ).trim();
+					var propValue = match[ 2 ].replace( /^"/, '' ).replace( /"$/, "" ).trim();
 
-            var parentId;
-            var parentNodes = node.searchConnectionParent( inId );
-            for (var pn=0; pn < parentNodes.length; ++pn) {
-                if ( this.isBoneNode( parentNodes[ pn ] )){
-                    parentId = parentNodes[ pn ];
-                    break;
-                }
-            }
+					this.parseNodeProperty( l, propName, propValue );
+					continue;
 
-            if( parentId !== undefined && localMatrices[ parentId] !== undefined ){
+				}
 
-                // convert world space matrix into local space
-                var inv = new THREE.Matrix4();
-                inv.getInverse( worldMatrices[ parentId ] );
-                inv.multiply( localMatrices[ inId ] );
-                localMatrices[ inId ] = inv;
+				// end of node
+				var endOfNodeExp = new RegExp( "^\\t{" + ( this.currentIndent - 1 ) + "}}" );
+				if ( l.match( endOfNodeExp ) ) {
 
-            } else {
-                //console.log( bone );
-            }
+					this.nodeEnd();
+					continue;
 
-            localMatrices[ inId ].decompose( t, r, s );
-            bone.pos  = [ t.x, t.y, t.z ];
-            bone.rotq = [ r.x, r.y, r.z, r.w ];
-            bone.scl  = [ s.x, s.y, s.z ];
+				}
 
-        }
-        
-    };
+				// for special case,
+				//
+				//	  Vertices: *8670 {
+				//		  a: 0.0356229953467846,13.9599733352661,-0.399196773.....(snip)
+				// -0.0612030513584614,13.960485458374,-0.409748703241348,-0.10.....
+				// 0.12490539252758,13.7450733184814,-0.454119384288788,0.09272.....
+				// 0.0836158767342567,13.5432004928589,-0.435397416353226,0.028.....
+				//
+				// these case the lines must contiue with previous line
+				if ( l.match( /^[^\s\t}]/ ) ) {
 
-    Bones.prototype.searchRealId = function ( internalId ) {
+					this.parseNodePropertyContinued( l );
 
-        for ( var h=0; h < this.hierarchy.length; h++ ){
-            if( internalId == this.hierarchy[h].internalId ){
-                return h;
-            }
-        }
+				}
 
-        // console.warn( 'FBXLoader: notfound internalId in bones: ' + internalId);
-        return -1;
+			}
 
-    };
+			console.timeEnd( 'FBXLoader: TextParser' );
+			return this.allNodes;
 
-    Bones.prototype.getByInternalId = function ( internalId ) {
 
-        for ( var h=0; h < this.hierarchy.length; h++ ){
-            if( internalId == this.hierarchy[h].internalId ){
-                return this.hierarchy[ h ];
-            }
-        }
+		},
 
-        return null;
+		parseNodeBegin: function ( line, nodeName, nodeAttrs ) {
 
-    };
+			// var nodeName = match[1];
+			var node = { 'name': nodeName, properties: {}, 'subNodes': {} };
+			var attrs = this.parseNodeAttr( nodeAttrs );
+			var currentNode = this.getCurrentNode();
 
-    Bones.prototype.isBoneNode = function  ( id ) {
+			// a top node
+			if ( this.currentIndent === 0 ) {
 
-        for (var i=0; i < this.hierarchy.length; ++i) {
-            if( id === this.hierarchy[i].internalId ){
-                return true;
-            }
-        }
-        return false;
-    };
+				this.allNodes.add( nodeName, node );
 
-    Bones.prototype.getBoneIdfromInternalId = function ( node, id ) {
+			} else {
 
-        if ( node.__cache_get_boneid_from_internalid === undefined ){
-            node.__cache_get_boneid_from_internalid = [];
-        }
+				// a subnode
 
-        if ( node.__cache_get_boneid_from_internalid[ id ] !== undefined ){
-            return node.__cache_get_boneid_from_internalid[ id ];
-        }
+				// already exists subnode, then append it
+				if ( nodeName in currentNode.subNodes ) {
 
-        for (var i=0; i < this.hierarchy.length; ++i) {
-            if( this.hierarchy[i].internalId == id ){
-                var res = i;
-                node.__cache_get_boneid_from_internalid[ id ] = i;
-                return i;
-            }
-        }
+					var tmp = currentNode.subNodes[ nodeName ];
 
-        // console.warn( 'FBXLoader: bone internalId(' + id + ') not found in bone hierarchy' );
-        return -1;
+					// console.log( "duped entry found\nkey: " + nodeName + "\nvalue: " + propValue );
+					if ( this.isFlattenNode( currentNode.subNodes[ nodeName ] ) ) {
 
-    };
 
+						if ( attrs.id === '' ) {
 
-    function Geometry() {
-     
-        this.node = null;
-        this.name = null;
-        this.id   = null;
+							currentNode.subNodes[ nodeName ] = [];
+							currentNode.subNodes[ nodeName ].push( tmp );
 
-        this.vertices = [];
-        this.indices = [];
-        this.normals = [];
-        this.uvs = [];
+						} else {
 
-        this.bones = [];
-        this.skins = null;
-    
-    }
+							currentNode.subNodes[ nodeName ] = {};
+							currentNode.subNodes[ nodeName ][ tmp.id ] = tmp;
 
-    Geometry.prototype.parse = function ( geoNode ) {
+						}
 
-        this.node = geoNode;
-        this.name = geoNode.attrName;
-        this.id   = geoNode.id;
+					}
 
-        this.vertices  = this.getVertices();
+					if ( attrs.id === '' ) {
 
-        if ( this.vertices === undefined ){
-            console.log( 'FBXLoader: Geometry.parse(): pass' + this.node.id );
-            return;
-        }
+						currentNode.subNodes[ nodeName ].push( node );
 
-        this.indices   = this.getPolygonVertexIndices();
-        this.uvs       = ( new UV() ).parse( this.node, this );
-        this.normals   = ( new Normal() ).parse( this.node, this );
+					} else {
 
-        if ( this.getPolygonTopologyMax() > 3 ){
+						currentNode.subNodes[ nodeName ][ attrs.id ] = node;
 
-            this.indices = this.convertPolyIndicesToTri(
-                                this.indices, this.getPolygonTopologyArray() );
+					}
 
-        }
+				} else {
 
-        return this;
+					currentNode.subNodes[ nodeName ] = node;
 
-    };
+				}
 
+			}
 
-    Geometry.prototype.getVertices = function () {
+			// for this		  ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
+			// NodeAttribute: 1001463072, "NodeAttribute::", "LimbNode" {
+			if ( nodeAttrs ) {
 
-        if ( this.node.__cache_vertices ){
-            return this.node.__cache_vertices;
-        }
+				node.id = attrs.id;
+				node.attrName = attrs.name;
+				node.attrType = attrs.type;
 
-        if ( this.node.subNodes.Vertices === undefined ){
-            console.warn( 'this.node: ' + this.node.attrName + "(" + this.node.id + ") does not have Vertices" );
-            this.node.__cache_vertices = undefined;
-            return null;
-        }
+			}
 
-        var rawTextVert    = this.node.subNodes.Vertices.properties.a;
-        var vertices  = rawTextVert.split( ',' ).map( function ( element ) {
-            return parseFloat( element );
-        } );
+			this.pushStack( node );
 
-        this.node.__cache_vertices = vertices;
-        return this.node.__cache_vertices;
+		},
 
-    };
+		parseNodeAttr: function ( attrs ) {
 
-    Geometry.prototype.getPolygonVertexIndices = function (){
+			var id = attrs[ 0 ];
 
-        if ( this.node.__cache_indices && this.node.__cache_poly_topology_max ){
-            return this.node.__cache_indices;
-        }
+			if ( attrs[ 0 ] !== "" ) {
 
-        if ( this.node.subNodes === undefined ){
-            console.error( 'this.node.subNodes undefined' );
-            console.log( this.node );
-            return;
-        }
+				id = parseInt( attrs[ 0 ] );
 
-        if ( this.node.subNodes.PolygonVertexIndex === undefined ){
-            console.warn( 'this.node: ' + this.node.attrName + "(" + this.node.id + ") does not have PolygonVertexIndex " );
-            this.node.__cache_indices = undefined;
-            return;
-        }
+				if ( isNaN( id ) ) {
 
-        var rawTextIndices = this.node.subNodes.PolygonVertexIndex.properties.a;
-        var indices = rawTextIndices.split( ',' );
+					// PolygonVertexIndex: *16380 {
+					id = attrs[ 0 ];
 
-        var currentTopo = 1;
-        var topologyN = null;
-        var topologyArr = [];
+				}
 
-        // The indices that make up the polygon are in order and a negative index
-        // means that it’s the last index of the polygon. That index needs
-        // to be made positive and then you have to subtract 1 from it!
-        for (var i=0; i < indices.length; ++i) {
+			}
 
-            var tmpI = parseInt( indices[i] );
-            // found n
-            if (  tmpI < 0 ) {
-                if( currentTopo > topologyN ) { topologyN =  currentTopo; }
+			var name;
+			var type;
+			if ( attrs.length > 1 ) {
 
-                indices[i] = tmpI ^ -1;
-                topologyArr.push( currentTopo );
-                currentTopo = 1;
+				name = attrs[ 1 ].replace( /^(\w+)::/, '' );
+				type = attrs[ 2 ];
 
-            } else {
+			}
 
-                indices[i] = tmpI;
-                currentTopo++;
-            }
+			return { id: id, name: name || '', type: type || '' };
 
-        }
+		},
 
-        if( topologyN === null ) {
-            console.warn( "FBXLoader: topology N not found: " + this.node.attrName );
-            console.warn( this.node );
-            topologyN =  3;
-        }
+		parseNodeProperty: function ( line, propName, propValue ) {
 
-        this.node.__cache_poly_topology_max = topologyN;
-        this.node.__cache_poly_topology_arr = topologyArr;
-        this.node.__cache_indices = indices;
+			var currentNode = this.getCurrentNode();
+			var parentName = currentNode.name;
 
-        return this.node.__cache_indices;
+			// special case parent node's is like "Properties70"
+			// these chilren nodes must treat with careful
+			if ( parentName !== undefined ) {
 
-    };
+				var propMatch = parentName.match( /Properties(\d)+/ );
+				if ( propMatch ) {
 
-    Geometry.prototype.getPolygonTopologyMax = function () {
+					this.parseNodeSpecialProperty( line, propName, propValue );
+					return;
 
-        if ( this.node.__cache_indices && this.node.__cache_poly_topology_max ){
-            return this.node.__cache_poly_topology_max;
-        }
+				}
 
-        this.getPolygonVertexIndices( this.node );
-        return this.node.__cache_poly_topology_max;
+			}
 
-    };
+			// special case Connections
+			if ( propName == 'C' ) {
 
-    Geometry.prototype.getPolygonTopologyArray = function  () {
+				var connProps = propValue.split( ',' ).slice( 1 );
+				var from = parseInt( connProps[ 0 ] );
+				var to = parseInt( connProps[ 1 ] );
 
-        if ( this.node.__cache_indices && this.node.__cache_poly_topology_max ){
-            return this.node.__cache_poly_topology_arr;
-        }
+				var rest = propValue.split( ',' ).slice( 3 );
 
-        this.getPolygonVertexIndices( this.node );
-        return this.node.__cache_poly_topology_arr;
+				propName = 'connections';
+				propValue = [ from, to ];
+				propValue = propValue.concat( rest );
 
-    };
+				if ( currentNode.properties[ propName ] === undefined ) {
 
-    // a - d
-    // |   |
-    // b - c
-    //
-    // [( a, b, c, d ) ...........
-    // [( a, b, c ), (a, c, d )....
-    Geometry.prototype.convertPolyIndicesToTri = function ( indices, strides ) {
+					currentNode.properties[ propName ] = [];
 
-        var res = [];
+				}
 
-        var i = 0;
-        var tmp = [];
-        var currentPolyNum  = 0;
-        var currentStride = 0;
+			}
 
-        while ( i < indices.length ) {
-            currentStride = strides[ currentPolyNum ];
+			// special case Connections
+			if ( propName == 'Node' ) {
 
-            // CAUTIN: NG over 6gon
-            for ( var j=0; j <= (currentStride - 3); j++ ){
+				var id = parseInt( propValue );
+				currentNode.properties.id = id;
+				currentNode.id = id;
 
-                res.push( indices[ i                             ] );
-                res.push( indices[ i + ( currentStride - 2 - j ) ] );
-                res.push( indices[ i + ( currentStride - 1 - j ) ] );
+			}
 
-            }
+			// already exists in properties, then append this
+			if ( propName in currentNode.properties ) {
 
-            currentPolyNum++;
-            i += currentStride;
+				// console.log( "duped entry found\nkey: " + propName + "\nvalue: " + propValue );
+				if ( Array.isArray( currentNode.properties[ propName ] ) ) {
 
-        }
+					currentNode.properties[ propName ].push( propValue );
 
-        return res;
+				} else {
 
-    };
+					currentNode.properties[ propName ] += propValue;
 
-    Geometry.prototype.addBones = function ( bones ) {
-        this.bones = bones;
-    };
+				}
 
+			} else {
 
-    function UV () {
+				// console.log( propName + ":  " + propValue );
+				if ( Array.isArray( currentNode.properties[ propName ] ) ) {
 
-        this.uv = null;
-        this.map = null;
-        this.ref = null;
-        this.node = null;
-        this.index = null;
+					currentNode.properties[ propName ].push( propValue );
 
-    }
+				} else {
 
-    UV.prototype.getUV = function ( node ){
+					currentNode.properties[ propName ] = propValue;
 
-        if ( this.node && this.uv && this.map && this.ref ) {
+				}
 
-            return this.uv;
+			}
 
-        } else {
+			this.setCurrentProp( currentNode.properties, propName );
 
-            return this._parseText( node );
-        }
+		},
 
-    };
+		// TODO:
+		parseNodePropertyContinued: function ( line ) {
 
-    UV.prototype.getMap = function ( node ){
+			this.currentProp[ this.currentPropName ] += line;
 
-        if ( this.node && this.uv && this.map && this.ref ) {
+		},
 
-            return this.map;
+		parseNodeSpecialProperty: function ( line, propName, propValue ) {
 
-        } else {
+			// split this
+			// P: "Lcl Scaling", "Lcl Scaling", "", "A",1,1,1
+			// into array like below
+			// ["Lcl Scaling", "Lcl Scaling", "", "A", "1,1,1" ]
+			var props = propValue.split( '",' ).map( function ( element ) {
 
-            this._parseText( node );
-            return this.map;
-        }
+				return element.trim().replace( /^\"/, '' ).replace( /\s/, '_' );
 
-    };
+			} );
 
-    UV.prototype.getRef = function ( node ){
+			var innerPropName = props[ 0 ];
+			var innerPropType1 = props[ 1 ];
+			var innerPropType2 = props[ 2 ];
+			var innerPropFlag = props[ 3 ];
+			var innerPropValue = props[ 4 ];
 
-        if ( this.node && this.uv && this.map && this.ref ) {
+			/*
+			if ( innerPropValue === undefined ) {
+				innerPropValue = props[3];
+			}
+			*/
 
-            return this.ref;
+			// cast value in its type
+			switch ( innerPropType1 ) {
 
-        } else {
+				case "int":
+					innerPropValue = parseInt( innerPropValue );
+					break;
 
-            this._parseText( node );
-            return this.ref;
-        }
+				case "double":
+					innerPropValue = parseFloat( innerPropValue );
+					break;
 
-    };
+				case "ColorRGB":
+				case "Vector3D":
+					var tmp = innerPropValue.split( ',' );
+					innerPropValue = new THREE.Vector3( tmp[ 0 ], tmp[ 1 ], tmp[ 2 ] );
+					break;
 
-    UV.prototype.getIndex = function ( node ){
+			}
 
-        if ( this.node && this.uv && this.map && this.ref ) {
+			// CAUTION: these props must append to parent's parent
+			this.getPrevNode().properties[ innerPropName ] = {
 
-            return this.index;
+				'type': innerPropType1,
+				'type2': innerPropType2,
+				'flag': innerPropFlag,
+				'value': innerPropValue
 
-        } else {
+			};
 
-            this._parseText( node );
-            return this.index;
-        }
+			this.setCurrentProp( this.getPrevNode().properties, innerPropName );
 
-    };
+		},
 
-    UV.prototype.getNode = function ( topnode ){
-        if ( this.node !== null ){
-            return this.node;
-        }
+		nodeEnd: function ( line ) {
 
-        this.node = topnode.subNodes.LayerElementUV;
-        return this.node;
-    };
+			this.popStack();
 
-    UV.prototype._parseText = function ( node ){
+		},
 
-        var uvNode  = this.getNode( node );
-        if ( uvNode === undefined ){
-            // console.log( node.attrName + "(" + node.id + ")" + " has no LayerElementUV." );
-            return [];
-        }
+		/* ---------------------------------------------------------------- */
+		/*		util													  */
+		isFlattenNode: function ( node ) {
 
-        var count = 0;
-        var x = '';
-        for ( var n in uvNode ){
-            if ( n.match( /^\d+$/ ) ){
-                count++;
-                x = n;
-            }
-        }
+			return ( 'subNodes' in node && 'properties' in node ) ? true : false;
 
-        if ( count > 0 ){
-            console.warn( 'multi uv not supported' );
-            uvNode = uvNode[n];
-        }
+		}
 
-        var uvIndex = uvNode.subNodes.UVIndex.properties.a;
-        var uvs     = uvNode.subNodes.UV.properties.a;
-        var uvMap   = uvNode.properties.MappingInformationType;
-        var uvRef   = uvNode.properties.ReferenceInformationType;
+	};
 
+	function FBXAnalyzer() {}
 
-        this.uv    = toFloat( uvs.split( ',' ) );
-        this.index = toInt( uvIndex.split( ',' ) );
+	FBXAnalyzer.prototype = {
 
-        this.map   = uvMap;  // TODO: normalize notation shaking... FOR BLENDER
-        this.ref   = uvRef;
+	};
 
-        return this.uv;
 
-    };
+	// generate skinIndices, skinWeights
+	//	  @skinIndices: per vertex data, this represents the bone indexes affects that vertex
+	//	  @skinWeights: per vertex data, this represents the Weight Values affects that vertex
+	//	  @matrices:	per `bones` data
+	function Weights() {
 
-    UV.prototype.parse = function ( node, geo ){
+		this.skinIndices = [];
+		this.skinWeights = [];
 
-        this.uvNode      = this.getNode( node );
+		this.matrices	= [];
 
-        this.uv         = this.getUV( node );
-        var mappingType = this.getMap( node );
-        var refType     = this.getRef( node );
-        var indices     = this.getIndex( node );
+	}
 
-        var strides     = geo.getPolygonTopologyArray();
 
-        // it means that there is a normal for every vertex of every polygon of the model.
-        // For example, if the models has 8 vertices that make up four quads, then there
-        // will be 16 normals (one normal * 4 polygons * 4 vertices of the polygon). Note
-        // that generally a game engine needs the vertices to have only one normal defined.
-        // So, if you find a vertex has more tha one normal, you can either ignore the normals
-        // you find after the first, or calculate the mean from all of them (normal smoothing).
-        //if ( mappingType == "ByPolygonVertex" ){
-        switch ( mappingType ) {
+	Weights.prototype.parseCluster = function ( node, id, entry ) {
 
-            case "ByPolygonVertex":
+		var _p = node.searchConnectionParent( id );
+		var _indices = toInt( entry.subNodes.Indexes.properties.a.split( ',' ) );
+		var _weights = toFloat( entry.subNodes.Weights.properties.a.split( ',' ) );
+		var _transform = toMat44( toFloat( entry.subNodes.Transform.properties.a.split( ',' ) ) );
+		var _link = toMat44( toFloat( entry.subNodes.TransformLink.properties.a.split( ',' ) ) );
 
-                switch ( refType ) {
+		return {
 
-                    // Direct
-                    // The this.uv are in order.
-                    case "Direct":
-                        this.uv = this.parseUV_ByPolygonVertex_Direct( this.uv, indices, strides, 2 );
-                        break;
+			'parent': _p,
+			'id': parseInt( id ),
+			'indices': _indices,
+			'weights': _weights,
+			'transform': _transform,
+			'transformlink': _link,
+			'linkMode': entry.properties.Mode
 
-                    // IndexToDirect
-                    // The order of the this.uv is given by the uvsIndex property.
-                    case "IndexToDirect":
-                        this.uv = this.parseUV_ByPolygonVertex_IndexToDirect( this.uv, indices );
-                        break;
+		};
 
-                }
+	};
 
-                // convert from by polygon(vert) data into by verts data
-                this.uv = mapByPolygonVertexToByVertex( this.uv,  geo.getPolygonVertexIndices( node ), 2 );
-                break;
+	Weights.prototype.parse = function ( node, bones ) {
 
-            case "ByPolygon":
+		this.skinIndices = [];
+		this.skinWeights = [];
 
-                switch ( refType ) {
+		this.matrices = [];
 
-                    // Direct
-                    // The this.uv are in order.
-                    case "Direct":
-                        this.uv = this.parseUV_ByPolygon_Direct();
-                        break;
+		var deformers = node.Objects.subNodes.Deformer;
 
-                    // IndexToDirect
-                    // The order of the this.uv is given by the uvsIndex property.
-                    case "IndexToDirect":
-                        this.uv = this.parseUV_ByPolygon_IndexToDirect();
-                        break;
+		var clusters = {};
+		for ( var id in deformers ) {
 
-                }
-                break;
-        }
+			if ( deformers[ id ].attrType === 'Cluster' ) {
 
-        return this.uv;
+				if ( ! ( 'Indexes' in deformers[ id ].subNodes ) ) {
 
-    };
+					continue;
 
-    UV.prototype.parseUV_ByPolygonVertex_Direct = function ( node, indices, strides, itemSize ) {
+				}
 
-        return parse_Data_ByPolygonVertex_Direct( node, indices, strides, itemSize );
+				//clusters.push( this.parseCluster( node, id, deformers[id] ) );
+				var cluster = this.parseCluster( node, id, deformers[ id ] );
+				var boneId = node.searchConnectionChildren( cluster.id )[ 0 ];
+				clusters[ boneId ] = cluster;
 
-    };
+			}
 
-    UV.prototype.parseUV_ByPolygonVertex_IndexToDirect = function ( node, indices ) {
+		}
 
-        return parse_Data_ByPolygonVertex_IndexToDirect( node, indices, 2 );
 
-    };
+		// this clusters is per Bone data, thus we make this into per vertex data
+		var weights = [];
+		var hi = bones.hierarchy;
+		for ( var b = 0; b < hi.length; ++ b ) {
 
-    UV.prototype.parseUV_ByPolygon_Direct = function ( node ) {
+			var bid = hi[ b ].internalId;
+			if ( clusters[ bid ] === undefined ) {
 
-        console.warn( "not implemented" );
-        return node;
+				//console.log( bid );
+				this.matrices.push( new THREE.Matrix4() );
+				continue;
 
-    };
+			}
 
-    UV.prototype.parseUV_ByPolygon_IndexToDirect = function ( node ) {
+			var clst = clusters[ bid ];
+			// store transform matrix per bones
+			this.matrices.push( clst.transform );
+			//this.matrices.push( clst.transformlink );
+			for ( var v = 0; v < clst.indices.length; ++ v ) {
 
-        console.warn( "not implemented" );
-        return node;
+				if ( weights[ clst.indices[ v ] ] === undefined ) {
 
-    };
+					weights[ clst.indices[ v ] ] = {};
+					weights[ clst.indices[ v ] ].joint = [];
+					weights[ clst.indices[ v ] ].weight = [];
 
-    UV.prototype.parseUV_ByVertex_Direct = function ( node ) {
+				}
 
-        console.warn( "not implemented" );
-        return node;
+				// indices
+				var affect = node.searchConnectionChildren( clst.id );
 
-    };
+				if ( affect.length > 1 ) {
 
+					console.warn( "FBXLoader: node " + clst.id + " have many weight kids: " + affect );
 
-    function Normal () {
+				}
+				weights[ clst.indices[ v ] ].joint.push( bones.getBoneIdfromInternalId( node, affect[ 0 ] ) );
 
-        this.normal = null;
-        this.map    = null;
-        this.ref    = null;
-        this.node   = null;
-        this.index  = null;
+				// weight value
+				weights[ clst.indices[ v ] ].weight.push( clst.weights[ v ] );
 
-    }
+			}
 
-    Normal.prototype.getNormal = function ( node ){
+		}
 
-        if ( this.node && this.normal && this.map && this.ref ) {
+		// normalize the skin weights
+		// TODO -  this might be a good place to choose greatest 4 weights
+		for ( var i = 0; i < weights.length; i ++ ) {
 
-            return this.normal;
+			var indicies = new THREE.Vector4(
+				weights[ i ].joint[ 0 ] ? weights[ i ].joint[ 0 ] : 0,
+				weights[ i ].joint[ 1 ] ? weights[ i ].joint[ 1 ] : 0,
+				weights[ i ].joint[ 2 ] ? weights[ i ].joint[ 2 ] : 0,
+				weights[ i ].joint[ 3 ] ? weights[ i ].joint[ 3 ] : 0 );
 
-        } else {
+			var weight = new THREE.Vector4(
+				weights[ i ].weight[ 0 ] ? weights[ i ].weight[ 0 ] : 0,
+				weights[ i ].weight[ 1 ] ? weights[ i ].weight[ 1 ] : 0,
+				weights[ i ].weight[ 2 ] ? weights[ i ].weight[ 2 ] : 0,
+				weights[ i ].weight[ 3 ] ? weights[ i ].weight[ 3 ] : 0 );
 
-            this._parseText( node );
-            return this.normal;
-        }
+			this.skinIndices.push( indicies );
+			this.skinWeights.push( weight );
 
-    };
+		}
 
-    // mappingType: possible variant
-    //      ByPolygon
-    //      ByPolygonVertex
-    //      ByVertex (or also ByVertice, as the Blender exporter writes)
-    //      ByEdge
-    //      AllSame
-    //    var mappingType = node.properties.MappingInformationType;
-    Normal.prototype.getMap = function ( node ){
+		//console.log( this );
+		return this;
 
-        if ( this.node && this.normal && this.map && this.ref ) {
+	};
 
-            return this.map;
+	function Bones() {
 
-        } else {
+		// returns bones hierarchy tree.
+		//	  [
+		//		  {
+		//			  "parent": id,
+		//			  "name": name,
+		//			  "pos": pos,
+		//			  "rotq": quat
+		//		  },
+		//		  ...
+		//		  {},
+		//		  ...
+		//	  ]
+		//
+		/* sample response
 
-            this._parseText( node );
-            return this.map;
-        }
+		   "bones" : [
+			{"parent":-1, "name":"Fbx01",			"pos":[-0.002,	 98.739,   1.6e-05],	 "rotq":[0, 0, 0, 1]},
+			{"parent":0,  "name":"Fbx01_Pelvis",	 "pos":[0.00015963, 0,		7.33107e-08], "rotq":[0, 0, 0, 1]},
+			{"parent":1,  "name":"Fbx01_Spine",	  "pos":[6.577e-06,  10.216,   0.0106811],   "rotq":[0, 0, 0, 1]},
+			{"parent":2,  "name":"Fbx01_R_Thigh",	"pos":[14.6537,	-10.216,  -0.00918758], "rotq":[0, 0, 0, 1]},
+			{"parent":3,  "name":"Fbx01_R_Calf",	 "pos":[-3.70047,	 -42.9681,	 -7.78158],	 "rotq":[0, 0, 0, 1]},
+			{"parent":4,  "name":"Fbx01_R_Foot",	 "pos":[-2.0696,	  -46.0488,	 9.42052],	  "rotq":[0, 0, 0, 1]},
+			{"parent":5,  "name":"Fbx01_R_Toe0",	 "pos":[-0.0234785,   -9.46233,	 -15.3187],	 "rotq":[0, 0, 0, 1]},
+			{"parent":2,  "name":"Fbx01_L_Thigh",	"pos":[-14.6537,	 -10.216,	  -0.00918314],  "rotq":[0, 0, 0, 1]},
+			{"parent":7,  "name":"Fbx01_L_Calf",	 "pos":[3.70037,	  -42.968,	  -7.78155],	 "rotq":[0, 0, 0, 1]},
+			{"parent":8,  "name":"Fbx01_L_Foot",	 "pos":[2.06954,	  -46.0488,	 9.42052],	  "rotq":[0, 0, 0, 1]},
+			{"parent":9,  "name":"Fbx01_L_Toe0",	 "pos":[0.0234566,	-9.46235,	 -15.3187],	 "rotq":[0, 0, 0, 1]},
+			{"parent":2,  "name":"Fbx01_Spine1",	 "pos":[-2.97523e-05, 11.5892,	  -9.81027e-05], "rotq":[0, 0, 0, 1]},
+			{"parent":11, "name":"Fbx01_Spine2",	 "pos":[-2.91292e-05, 11.4685,	  8.27126e-05],  "rotq":[0, 0, 0, 1]},
+			{"parent":12, "name":"Fbx01_Spine3",	 "pos":[-4.48857e-05, 11.5783,	  8.35108e-05],  "rotq":[0, 0, 0, 1]},
+			{"parent":13, "name":"Fbx01_Neck",	   "pos":[1.22987e-05,  11.5582,	  -0.0044775],   "rotq":[0, 0, 0, 1]},
+			{"parent":14, "name":"Fbx01_Head",	   "pos":[-3.50709e-05, 6.62915,	  -0.00523254],  "rotq":[0, 0, 0, 1]},
+			{"parent":15, "name":"Fbx01_R_Eye",	  "pos":[3.31681,	  12.739,	   -10.5267],	 "rotq":[0, 0, 0, 1]},
+			{"parent":15, "name":"Fbx01_L_Eye",	  "pos":[-3.32038,	 12.7391,	  -10.5267],	 "rotq":[0, 0, 0, 1]},
+			{"parent":15, "name":"Jaw",			  "pos":[-0.0017738,   7.43481,	  -4.08114],	 "rotq":[0, 0, 0, 1]},
+			{"parent":14, "name":"Fbx01_R_Clavicle", "pos":[3.10919,	  2.46577,	  -0.0115284],   "rotq":[0, 0, 0, 1]},
+			{"parent":19, "name":"Fbx01_R_UpperArm", "pos":[16.014,	   4.57764e-05,  3.10405],	  "rotq":[0, 0, 0, 1]},
+			{"parent":20, "name":"Fbx01_R_Forearm",  "pos":[22.7068,	  -1.66322,	 -2.13803],	 "rotq":[0, 0, 0, 1]},
+			{"parent":21, "name":"Fbx01_R_Hand",	 "pos":[25.5881,	  -0.80249,	 -6.37307],	 "rotq":[0, 0, 0, 1]},
+			...
+			{"parent":27, "name":"Fbx01_R_Finger32", "pos":[2.15572,	  -0.548737,	-0.539604],	"rotq":[0, 0, 0, 1]},
+			{"parent":22, "name":"Fbx01_R_Finger2",  "pos":[9.79318,	  0.132553,	 -2.97845],	 "rotq":[0, 0, 0, 1]},
+			{"parent":29, "name":"Fbx01_R_Finger21", "pos":[2.74037,	  0.0483093,	-0.650531],	"rotq":[0, 0, 0, 1]},
+			{"parent":55, "name":"Fbx01_L_Finger02", "pos":[-1.65308,	 -1.43208,	 -1.82885],	 "rotq":[0, 0, 0, 1]}
+			]
+		*/
+		this.hierarchy = [];
 
-    };
+	}
 
-    // refType: possible variants
-    //      Direct
-    //      IndexToDirect (or Index for older versions)
-    // var refType     = node.properties.ReferenceInformationType;
-    Normal.prototype.getRef = function ( node ){
+	Bones.prototype.parseHierarchy = function ( node ) {
 
-        if ( this.node && this.normal && this.map && this.ref ) {
+		var objects = node.Objects;
+		var models = objects.subNodes.Model;
 
-            return this.ref;
+		var bones = [];
+		for ( var id in models ) {
 
-        } else {
+			if ( models[ id ].attrType === undefined ) {
 
-            this._parseText( node );
-            return this.ref;
-        }
+				continue;
 
-    };
+			}
+			bones.push( models[ id ] );
 
-    Normal.prototype.getNode = function ( node ){
+		}
 
-        if ( this.node ){
-            return this.node;
-        }
+		this.hierarchy = [];
+		for ( var i = 0; i < bones.length; ++ i ) {
 
-        this.node = node.subNodes.LayerElementNormal;
-        return this.node;
+			var bone = bones[ i ];
 
-    };
+			var p = node.searchConnectionParent( bone.id )[ 0 ];
+			var t = [ 0.0, 0.0, 0.0 ];
+			var r = [ 0.0, 0.0, 0.0, 1.0 ];
+			var s = [ 1.0, 1.0, 1.0 ];
 
-    Normal.prototype._parseText = function ( node ) {
+			if ( 'Lcl_Translation' in bone.properties ) {
 
-        var normalNode  = this.getNode( node );
+				t = toFloat( bone.properties.Lcl_Translation.value.split( ',' ) );
 
-        if ( normalNode === undefined ){
-            console.warn( 'node: ' + node.attrName + "(" + node.id + ") does not have LayerElementNormal" );
-            return;
-        }
+			}
 
-        var mappingType = normalNode.properties.MappingInformationType;
-        var refType     = normalNode.properties.ReferenceInformationType;
+			if ( 'Lcl_Rotation' in bone.properties ) {
 
-        var rawTextNormals = normalNode.subNodes.Normals.properties.a;
-        this.normal  = toFloat( rawTextNormals.split( ',' ) );
+				r = toRad( toFloat( bone.properties.Lcl_Rotation.value.split( ',' ) ) );
+				var q = new THREE.Quaternion();
+				q.setFromEuler( new THREE.Euler( r[ 0 ], r[ 1 ], r[ 2 ], 'ZYX' ) );
+				r = [ q.x, q.y, q.z, q.w ];
 
-        // TODO: normalize notation shaking, vertex / vertice... blender...
-        this.map    = mappingType;
-        this.ref    = refType;
+			}
 
-    };
+			if ( 'Lcl_Scaling' in bone.properties ) {
 
-    Normal.prototype.parse = function ( topnode, geo ) {
+				s = toFloat( bone.properties.Lcl_Scaling.value.split( ',' ) );
 
-        var normals     = this.getNormal( topnode );
-        var normalNode  = this.getNode( topnode );
-        var mappingType = this.getMap( topnode );
-        var refType     = this.getRef( topnode );
+			}
 
-        var indices     = geo.getPolygonVertexIndices( topnode );
-        var strides     = geo.getPolygonTopologyArray( topnode );
+			// replace unsafe character
+			var name = bone.attrName;
+			name = name.replace( /:/, '' );
+			name = name.replace( /_/, '' );
+			name = name.replace( /-/, '' );
+			this.hierarchy.push( { "parent": p, "name": name, "pos": t, "rotq": r, "scl": s, "internalId": bone.id } );
 
-        // it means that there is a normal for every vertex of every polygon of the model.
-        // For example, if the models has 8 vertices that make up four quads, then there
-        // will be 16 normals (one normal * 4 polygons * 4 vertices of the polygon). Note
-        // that generally a game engine needs the vertices to have only one normal defined.
-        // So, if you find a vertex has more tha one normal, you can either ignore the normals
-        // you find after the first, or calculate the mean from all of them (normal smoothing).
-        //if ( mappingType == "ByPolygonVertex" ){
-        switch ( mappingType ) {
+		}
 
-            case "ByPolygonVertex":
+		this.reindexParentId();
 
-                switch ( refType ) {
+		this.restoreBindPose( node );
 
-                    // Direct
-                    // The normals are in order.
-                    case "Direct":
-                        normals = this.parseNormal_ByPolygonVertex_Direct( normals, indices, strides, 3 );
-                        break;
+		return this;
 
-                    // IndexToDirect
-                    // The order of the normals is given by the NormalsIndex property.
-                    case "IndexToDirect":
-                        normals = this.parseNormal_ByPolygonVertex_IndexToDirect();
-                        break;
+	};
 
-                }
-                break;
+	Bones.prototype.reindexParentId = function () {
 
-            case "ByPolygon":
+		for ( var h = 0; h < this.hierarchy.length; h ++ ) {
 
-                switch ( refType ) {
+			for ( var ii = 0; ii < this.hierarchy.length; ++ ii ) {
 
-                    // Direct
-                    // The normals are in order.
-                    case "Direct":
-                        normals = this.parseNormal_ByPolygon_Direct();
-                        break;
+				if ( this.hierarchy[ h ].parent == this.hierarchy[ ii ].internalId ) {
 
-                    // IndexToDirect
-                    // The order of the normals is given by the NormalsIndex property.
-                    case "IndexToDirect":
-                        normals = this.parseNormal_ByPolygon_IndexToDirect();
-                        break;
+					this.hierarchy[ h ].parent = ii;
+					break;
 
-                }
-                break;
-        }
+				}
 
-        return normals;
+			}
 
-    };
+		}
 
-    Normal.prototype.parseNormal_ByPolygonVertex_Direct = function ( node, indices, strides, itemSize ) {
+	};
 
-        return parse_Data_ByPolygonVertex_Direct( node, indices, strides, itemSize );
+	Bones.prototype.restoreBindPose = function ( node ) {
 
-    };
+		var bindPoseNode = node.Objects.subNodes.Pose;
+		if ( bindPoseNode === undefined ) {
 
-    Normal.prototype.parseNormal_ByPolygonVertex_IndexToDirect = function ( node ) {
+			return;
 
-        console.warn( "not implemented" );
-        return node;
+		}
 
-    };
+		var poseNode = bindPoseNode.subNodes.PoseNode;
+		var localMatrices = {}; // store local matrices, modified later( initialy world space )
+		var worldMatrices = {}; // store world matrices
 
-    Normal.prototype.parseNormal_ByPolygon_Direct = function ( node ) {
+		for ( var i = 0; i < poseNode.length; ++ i ) {
 
-        console.warn( "not implemented" );
-        return node;
+			var rawMatLcl = toMat44( poseNode[ i ].subNodes.Matrix.properties.a.split( ',' ) );
+			var rawMatWrd = toMat44( poseNode[ i ].subNodes.Matrix.properties.a.split( ',' ) );
 
-    };
+			localMatrices[ poseNode[ i ].id ] = rawMatLcl;
+			worldMatrices[ poseNode[ i ].id ] = rawMatWrd;
 
-    Normal.prototype.parseNormal_ByPolygon_IndexToDirect = function ( node ) {
+		}
 
-        console.warn( "not implemented" );
-        return node;
+		for ( var h = 0; h < this.hierarchy.length; ++ h ) {
 
-    };
+			var bone = this.hierarchy[ h ];
+			var inId = bone.internalId;
 
-    Normal.prototype.parseNormal_ByVertex_Direct = function ( node ) {
+			if ( worldMatrices[ inId ] === undefined ) {
 
-        console.warn( "not implemented" );
-        return node;
+				// has no bind pose node, possibly be mesh
+				// console.log( bone );
+				continue;
 
-    };
+			}
 
-    function AnimationCurve () {
+			var t = new THREE.Vector3( 0, 0, 0 );
+			var r = new THREE.Quaternion();
+			var s = new THREE.Vector3( 1, 1, 1 );
 
-        this.version = null;
+			var parentId;
+			var parentNodes = node.searchConnectionParent( inId );
+			for ( var pn = 0; pn < parentNodes.length; ++ pn ) {
 
-        this.id         = null;
-        this.internalId = null;
-        this.times      = null;
-        this.values     = null;
+				if ( this.isBoneNode( parentNodes[ pn ] ) ) {
 
-        this.attrFlag   = null;  // tangeant
-        this.attrData   = null;  // slope, weight
+					parentId = parentNodes[ pn ];
+					break;
 
-    }
+				}
 
-    AnimationCurve.prototype.fromNode = function ( curveNode ){
+			}
 
-        this.id         = curveNode.id;
-        this.internalId = curveNode.id;
-        this.times      = curveNode.subNodes.KeyTime.properties.a;
-        this.values     = curveNode.subNodes.KeyValueFloat.properties.a;
+			if ( parentId !== undefined && localMatrices[ parentId ] !== undefined ) {
 
-        this.attrFlag   = curveNode.subNodes.KeyAttrFlags.properties.a;
-        this.attrData   = curveNode.subNodes.KeyAttrDataFloat.properties.a;
+				// convert world space matrix into local space
+				var inv = new THREE.Matrix4();
+				inv.getInverse( worldMatrices[ parentId ] );
+				inv.multiply( localMatrices[ inId ] );
+				localMatrices[ inId ] = inv;
 
-        this.times      = toFloat( this.times.split(    ',' ) );
-        this.values     = toFloat( this.values.split(   ',' ) );
-        this.attrData   = toFloat( this.attrData.split( ',' ) );
-        this.attrFlag   = toInt(   this.attrFlag.split( ',' ) );
+			} else {
+				//console.log( bone );
+			}
 
-        this.times = this.times.map( function ( element ) {
-            return FBXTimeToSeconds( element );
-        } );
+			localMatrices[ inId ].decompose( t, r, s );
+			bone.pos = [ t.x, t.y, t.z ];
+			bone.rotq = [ r.x, r.y, r.z, r.w ];
+			bone.scl = [ s.x, s.y, s.z ];
 
-        return this;
+		}
 
-    };
+	};
 
-    AnimationCurve.prototype.getLength = function () {
+	Bones.prototype.searchRealId = function ( internalId ) {
 
-        return this.times[ this.times.length - 1 ];
-    };
+		for ( var h = 0; h < this.hierarchy.length; h ++ ) {
 
-    function AnimationNode (){
+			if ( internalId == this.hierarchy[ h ].internalId ) {
 
-        this.id                  = null;
-        this.attr                = null;  // S, R, T
-        this.attrX               = false;
-        this.attrY               = false;
-        this.attrZ               = false;
-        this.internalId          = null;
-        this.containerInternalId = null;  // bone, null etc Id
-        this.containerBoneId     = null;  // bone, null etc Id
-        this.curveIdx            = null;  // AnimationCurve's indices
-        this.curves              = [];    // AnimationCurve refs
+				return h;
 
-    }
+			}
 
-    AnimationNode.prototype.fromNode = function ( allNodes, node, bones ){
+		}
 
-        this.id          = node.id;
-        this.attr        = node.attrName;
-        this.internalId  = node.id;
+		// console.warn( 'FBXLoader: notfound internalId in bones: ' + internalId);
+		return - 1;
 
-        if ( this.attr.match( /S|R|T/ ) ){
-            for ( var attrKey in node.properties ){
-                if ( attrKey.match( /X/ )) { this.attrX = true; }
-                if ( attrKey.match( /Y/ )) { this.attrY = true; }
-                if ( attrKey.match( /Z/ )) { this.attrZ = true; }
-            }
+	};
 
-        } else {
-            // may be deform percent nodes
-            return null;
-        }
+	Bones.prototype.getByInternalId = function ( internalId ) {
 
-        this.containerIndices = allNodes.searchConnectionParent( this.id );
-        this.curveIdx    = allNodes.searchConnectionChildren( this.id );
+		for ( var h = 0; h < this.hierarchy.length; h ++ ) {
 
-        for ( var i = this.containerIndices.length - 1; i>=0;  --i) {
+			if ( internalId == this.hierarchy[ h ].internalId ) {
 
-            var boneId = bones.searchRealId( this.containerIndices[ i ] );
-            if ( boneId >= 0 ) {
+				return this.hierarchy[ h ];
 
-                this.containerBoneId = boneId;
-                this.containerId = this.containerIndices [ i ];
-            }
+			}
 
-            if ( boneId >= 0 ){ break; }
-        }
-        // this.containerBoneId = bones.searchRealId( this.containerIndices );
+		}
 
-        return this;
+		return null;
 
-    };
+	};
 
-    AnimationNode.prototype.setCurve = function ( curve ){
-        this.curves.push( curve );
+	Bones.prototype.isBoneNode = function ( id ) {
 
-    };
+		for ( var i = 0; i < this.hierarchy.length; ++ i ) {
 
-    function Animation () {
+			if ( id === this.hierarchy[ i ].internalId ) {
 
-        this.curves = {};
-        this.length = 0.0;
-        this.fps    = 30.0;
-        this.frames = 0.0;
+				return true;
 
-    }
+			}
 
-    Animation.prototype.parse = function ( node, bones ) {
+		}
+		return false;
 
-        var rawNodes  = node.Objects.subNodes.AnimationCurveNode;
-        var rawCurves = node.Objects.subNodes.AnimationCurve;
+	};
 
-        // first: expand AnimationCurveNode into curve nodes
-        var curveNodes = [];
-        for ( var key in rawNodes ) {
+	Bones.prototype.getBoneIdfromInternalId = function ( node, id ) {
 
-            if ( key.match( /\d+/ ) ){
-                var a = ( new AnimationNode() ).fromNode( node, rawNodes[ key ], bones );
-                curveNodes.push( a );
-            }
+		if ( node.__cache_get_boneid_from_internalid === undefined ) {
 
-        }
+			node.__cache_get_boneid_from_internalid = [];
 
-        // second: gen dict, mapped by internalId
-        var tmp = {};
-        for (var i=0; i < curveNodes.length; ++i) {
-            if( curveNodes[i] === null ){ continue; }
+		}
 
-            tmp[ curveNodes[i].id ] = curveNodes[i];
-        }
+		if ( node.__cache_get_boneid_from_internalid[ id ] !== undefined ) {
 
-        // third: insert curves into the dict 
-        var ac = [];
-        var max = 0.0;
-        for ( key in rawCurves ) {
+			return node.__cache_get_boneid_from_internalid[ id ];
 
-            if ( key.match( /\d+/ ) ){
-                var c = ( new AnimationCurve() ).fromNode( rawCurves[key] );
-                ac.push( c );
-                max = c.getLength() ? c.getLength() : max;
+		}
 
-                var parentId = node.searchConnectionParent( c.id )[ 0 ];
-                var axis = node.searchConnectionType( c.id, parentId );
+		for ( var i = 0; i < this.hierarchy.length; ++ i ) {
 
-                if ( axis.match( /X/ ) ){ axis = 'x'; }
-                if ( axis.match( /Y/ ) ){ axis = 'y'; }
-                if ( axis.match( /Z/ ) ){ axis = 'z'; }
+			if ( this.hierarchy[ i ].internalId == id ) {
 
-                tmp[ parentId ].curves[ axis ] =  c;
-            }
+				var res = i;
+				node.__cache_get_boneid_from_internalid[ id ] = i;
+				return i;
 
-        }
+			}
 
-        // forth: 
-        for ( var t in tmp ){
-            var id = tmp[ t ].containerBoneId;
-            if( this.curves[ id ] === undefined ){
-                this.curves[ id ] = {};
-            }
+		}
 
-            this.curves[ id ][ tmp[ t ].attr ] = tmp[ t ];
-        }
+		// console.warn( 'FBXLoader: bone internalId(' + id + ') not found in bone hierarchy' );
+		return - 1;
 
-        this.length = max;
-        this.frames = this.length * this.fps;
+	};
 
-        return this;
 
-    };
+	function Geometry() {
 
+		this.node = null;
+		this.name = null;
+		this.id = null;
 
-    function Textures () {
+		this.vertices = [];
+		this.indices = [];
+		this.normals = [];
+		this.uvs = [];
 
-        this.textures  = [];
-        this.perGeoMap = {};
+		this.bones = [];
+		this.skins = null;
 
-    }
+	}
 
-    Textures.prototype.add = function ( tex ){
+	Geometry.prototype.parse = function ( geoNode ) {
 
-        if ( this.textures === undefined ) {
-            this.textures = [];
-        }
+		this.node = geoNode;
+		this.name = geoNode.attrName;
+		this.id = geoNode.id;
 
-        this.textures.push( tex );
+		this.vertices = this.getVertices();
 
-        for (var  i=0;  i < tex.parentIds.length; ++ i) {
-            
-            if ( this.perGeoMap[ tex.parentIds[ i ] ] === undefined ){
+		if ( this.vertices === undefined ) {
 
-                this.perGeoMap[ tex.parentIds[ i ] ] = [];
+			console.log( 'FBXLoader: Geometry.parse(): pass' + this.node.id );
+			return;
 
-            }
+		}
 
-            this.perGeoMap[ tex.parentIds[ i ] ].push( this.textures[ this.textures.length - 1 ] );
+		this.indices = this.getPolygonVertexIndices();
+		this.uvs = ( new UV() ).parse( this.node, this );
+		this.normals = ( new Normal() ).parse( this.node, this );
 
-        }
+		if ( this.getPolygonTopologyMax() > 3 ) {
 
-    };
+			this.indices = this.convertPolyIndicesToTri(
+								this.indices, this.getPolygonTopologyArray() );
 
-    Textures.prototype.parse = function ( node, bones ){
+		}
 
-        var rawNodes = node.Objects.subNodes.Texture;
+		return this;
 
-        for ( var n in rawNodes ) {
-            var tex = ( new Texture() ).parse( rawNodes[ n ], node );
-            this.add( tex );
-        }
+	};
 
-        return this;
 
-    };
+	Geometry.prototype.getVertices = function () {
 
-    Textures.prototype.getById = function ( id ) {
+		if ( this.node.__cache_vertices ) {
 
-        return this.perGeoMap[ id ];
-    };
+			return this.node.__cache_vertices;
 
-    function Texture () {
+		}
 
-        this.fileName  = "";
-        this.name      = "";
-        this.id        = null;
-        this.parentIds = [];
+		if ( this.node.subNodes.Vertices === undefined ) {
 
-    }
+			console.warn( 'this.node: ' + this.node.attrName + "(" + this.node.id + ") does not have Vertices" );
+			this.node.__cache_vertices = undefined;
+			return null;
 
-    Texture.prototype.parse = function ( node, nodes ){
-        
-        this.id = node.id;
-        this.name = node.attrName;
-        this.fileName = this.parseFileName( node.properties.FileName );
+		}
 
-        this.parentIds = this.searchParents( this.id, nodes );
+		var rawTextVert	= this.node.subNodes.Vertices.properties.a;
+		var vertices = rawTextVert.split( ',' ).map( function ( element ) {
 
-        return this;
+			return parseFloat( element );
 
-    };
+		} );
 
-    // TODO: support directory 
-    Texture.prototype.parseFileName = function ( fname ) {
+		this.node.__cache_vertices = vertices;
+		return this.node.__cache_vertices;
 
-        if ( fname === undefined ){ return ""; }
+	};
 
-        // ignore directory structure, flatten path
-        var splitted = fname.split( /[\\\/]/ );
-        if ( splitted.length > 0 ){
+	Geometry.prototype.getPolygonVertexIndices = function () {
 
-            return splitted[ splitted.length - 1 ];
+		if ( this.node.__cache_indices && this.node.__cache_poly_topology_max ) {
 
-        } else {
+			return this.node.__cache_indices;
 
-            return fname;
+		}
 
-        }
+		if ( this.node.subNodes === undefined ) {
 
-    };
+			console.error( 'this.node.subNodes undefined' );
+			console.log( this.node );
+			return;
 
-    Texture.prototype.searchParents = function ( id, nodes ) {
+		}
 
-        var p = nodes.searchConnectionParent( id );
+		if ( this.node.subNodes.PolygonVertexIndex === undefined ) {
 
-        return p;
-    };
+			console.warn( 'this.node: ' + this.node.attrName + "(" + this.node.id + ") does not have PolygonVertexIndex " );
+			this.node.__cache_indices = undefined;
+			return;
 
+		}
 
-    /* --------------------------------------------------------------------- */
-    /* --------------------------------------------------------------------- */
-    /* --------------------------------------------------------------------- */
-    /* --------------------------------------------------------------------- */
+		var rawTextIndices = this.node.subNodes.PolygonVertexIndex.properties.a;
+		var indices = rawTextIndices.split( ',' );
 
-    function loadTextureImage ( texture, url ) {
-        
-        var loader = new THREE.ImageLoader();
+		var currentTopo = 1;
+		var topologyN = null;
+		var topologyArr = [];
 
-        loader.load( url, function ( image ) {
-            
+		// The indices that make up the polygon are in order and a negative index
+		// means that it’s the last index of the polygon. That index needs
+		// to be made positive and then you have to subtract 1 from it!
+		for ( var i = 0; i < indices.length; ++ i ) {
 
-        } );
+			var tmpI = parseInt( indices[ i ] );
+			// found n
+			if ( tmpI < 0 ) {
 
-        loader.load( url, function( image ) {
+				if ( currentTopo > topologyN ) {
 
-                texture.image = image;
-                texture.needUpdate = true;
-                console.log( 'tex load done' );
+					topologyN = currentTopo;
 
-            },
+				}
 
-            // Function called when download progresses
-            function ( xhr ) {
-                console.log( (xhr.loaded / xhr.total * 100) + '% loaded' );
-            },
+				indices[ i ] = tmpI ^ - 1;
+				topologyArr.push( currentTopo );
+				currentTopo = 1;
 
-            // Function called when download errors
-            function ( xhr ) {
-                console.log( 'An error happened' );
-            }
-        );
+			} else {
 
-    }
+				indices[ i ] = tmpI;
+				currentTopo ++;
 
-    // LayerElementUV: 0 {
-    // 	Version: 101
-    //	Name: "Texture_Projection"
-    //	MappingInformationType: "ByPolygonVertex"
-    //	ReferenceInformationType: "IndexToDirect"
-    //	UV: *1746 {
-    //	UVIndex: *7068 {
-    //
-    //	The order of the uvs is given by the UVIndex property.
-    function parse_Data_ByPolygonVertex_IndexToDirect( node, indices, itemSize ) {
+			}
 
-        var res = [];
+		}
 
-        for (var i=0; i < indices.length; ++i ) {
+		if ( topologyN === null ) {
 
-            for (var j=0; j < itemSize; ++j) {
+			console.warn( "FBXLoader: topology N not found: " + this.node.attrName );
+			console.warn( this.node );
+			topologyN = 3;
 
-                res.push( node[ ( indices[i] * itemSize ) + j ] );
-                
-            }
+		}
 
-        }
+		this.node.__cache_poly_topology_max = topologyN;
+		this.node.__cache_poly_topology_arr = topologyArr;
+		this.node.__cache_indices = indices;
 
-        return res;
+		return this.node.__cache_indices;
 
-    }
+	};
 
+	Geometry.prototype.getPolygonTopologyMax = function () {
 
-    // what want: normal per vertex, order vertice
-    // i have: normal per polygon
-    // i have: indice per polygon
-    parse_Data_ByPolygonVertex_Direct = function ( node, indices, strides, itemSize ) {
+		if ( this.node.__cache_indices && this.node.__cache_poly_topology_max ) {
 
-        // *21204 > 3573
-        // Geometry: 690680816, "Geometry::", "Mesh" {
-        //  Vertices: *3573 {
-        //  PolygonVertexIndex: *7068 {
+			return this.node.__cache_poly_topology_max;
 
-        var tmp = [];
-        var currentIndex = 0;
+		}
 
-        // first: sort to per vertex
-        for (var i=0; i < indices.length; ++i) {
+		this.getPolygonVertexIndices( this.node );
+		return this.node.__cache_poly_topology_max;
 
-            tmp[ indices[i] ] = [];
+	};
 
-            // TODO: duped entry? blend or something?
-            for ( var s=0; s < itemSize; ++s ){
+	Geometry.prototype.getPolygonTopologyArray = function () {
 
-                tmp[ indices[i] ][ s ] = node[ currentIndex + s ];
+		if ( this.node.__cache_indices && this.node.__cache_poly_topology_max ) {
 
-            }
+			return this.node.__cache_poly_topology_arr;
 
-            currentIndex += itemSize;
+		}
 
-        }
+		this.getPolygonVertexIndices( this.node );
+		return this.node.__cache_poly_topology_arr;
 
-        // second: expand x,y,z into serial array
-        var res = [];
-        for ( var jj=0; jj < tmp.length; ++jj) {
-            if ( tmp[jj] === undefined ){ continue; }
+	};
 
-            for ( var t=0; t < itemSize; ++t ){
-                if ( tmp[jj][t] === undefined ){ continue; }
-                res.push( tmp[jj][t] );
-            }
-        }
+	// a - d
+	// |   |
+	// b - c
+	//
+	// [( a, b, c, d ) ...........
+	// [( a, b, c ), (a, c, d )....
+	Geometry.prototype.convertPolyIndicesToTri = function ( indices, strides ) {
 
-        return res;
+		var res = [];
 
-    };
+		var i = 0;
+		var tmp = [];
+		var currentPolyNum = 0;
+		var currentStride = 0;
 
-    // convert from by polygon(vert) data into by verts data
-    function mapByPolygonVertexToByVertex( data, indices, stride ) {
+		while ( i < indices.length ) {
 
-        var tmp = {};
-        var res = [];
-        var max = 0;
+			currentStride = strides[ currentPolyNum ];
 
-        for ( var i=0; i < indices.length; ++i ) {
-            if ( indices[i] in tmp ){ continue; }
+			// CAUTIN: NG over 6gon
+			for ( var j = 0; j <= ( currentStride - 3 ); j ++ ) {
 
-            tmp[ indices[i] ] = {};
+				res.push( indices[ i ] );
+				res.push( indices[ i + ( currentStride - 2 - j ) ] );
+				res.push( indices[ i + ( currentStride - 1 - j ) ] );
 
-            for (var j=0; j < stride; ++j) {
-                tmp[ indices[i] ][ j ] = data[ i*stride + j];
-            }
+			}
 
-            max =  max < indices[i] ? indices[i] : max;
-        }
+			currentPolyNum ++;
+			i += currentStride;
 
-        try {
-            for ( i=0; i <= max; i++ ){
+		}
 
-                for ( var s=0; s < stride; s++ ){
-                    res.push( tmp[ i ][ s ] );
-                }
+		return res;
 
-            }
-        } catch (e) {
-            //console.log( max );
-            //console.log( tmp );
-            //console.log( i );
-            //console.log( e );
-        }
+	};
 
-        return res;
+	Geometry.prototype.addBones = function ( bones ) {
 
-    }
+		this.bones = bones;
 
-    // AUTODESK uses broken clock. i guess
-    var FBXTimeToSeconds =  function( adskTime ){
-        return adskTime / 46186158000;
-    };
+	};
 
-    degToRad = function ( degrees ) {
-        return degrees * Math.PI / 180;
-    };
 
-    radToDeg = function ( radians ) {
-        return radians * 180 / Math.PI;
-    };
+	function UV() {
 
-    quatFromVec = function ( x, y, z ){
-        var euler = new THREE.Euler( x, y, z, 'ZYX' );
-        var quat  = new THREE.Quaternion();
-        quat.setFromEuler( euler );
+		this.uv = null;
+		this.map = null;
+		this.ref = null;
+		this.node = null;
+		this.index = null;
 
-        return quat;
-    };
+	}
 
+	UV.prototype.getUV = function ( node ) {
 
-    // extend Array.prototype ?  ....uuuh
-    toInt = function ( arr ) {
-        return arr.map( function ( element ) { return parseInt( element ); } );
-    };
+		if ( this.node && this.uv && this.map && this.ref ) {
 
-    toFloat = function ( arr ) {
-        return arr.map( function ( element ) { return parseFloat( element ); } );
-    };
+			return this.uv;
 
-    toRad = function ( arr ){
-        return arr.map( function ( element ) { return degToRad( element ); } );
-    };
+		} else {
 
-    toMat44 = function ( arr ) {
-        var mat = new THREE.Matrix4();
-        mat.set(
-            arr[ 0], arr[ 4], arr[ 8], arr[12],
-            arr[ 1], arr[ 5], arr[ 9], arr[13],
-            arr[ 2], arr[ 6], arr[10], arr[14],
-            arr[ 3], arr[ 7], arr[11], arr[15]
-        );
+			return this._parseText( node );
 
-        /*
-        mat.set(
-            arr[ 0], arr[ 1], arr[ 2], arr[ 3],
-            arr[ 4], arr[ 5], arr[ 6], arr[ 7],
-            arr[ 8], arr[ 9], arr[10], arr[11],
-            arr[12], arr[13], arr[14], arr[15]
-        );
-        // */
-        return mat;
-    };
+		}
+
+	};
+
+	UV.prototype.getMap = function ( node ) {
+
+		if ( this.node && this.uv && this.map && this.ref ) {
+
+			return this.map;
+
+		} else {
+
+			this._parseText( node );
+			return this.map;
+
+		}
+
+	};
+
+	UV.prototype.getRef = function ( node ) {
+
+		if ( this.node && this.uv && this.map && this.ref ) {
+
+			return this.ref;
+
+		} else {
+
+			this._parseText( node );
+			return this.ref;
+
+		}
+
+	};
+
+	UV.prototype.getIndex = function ( node ) {
+
+		if ( this.node && this.uv && this.map && this.ref ) {
+
+			return this.index;
+
+		} else {
+
+			this._parseText( node );
+			return this.index;
+
+		}
+
+	};
+
+	UV.prototype.getNode = function ( topnode ) {
+
+		if ( this.node !== null ) {
+
+			return this.node;
+
+		}
+
+		this.node = topnode.subNodes.LayerElementUV;
+		return this.node;
+
+	};
+
+	UV.prototype._parseText = function ( node ) {
+
+		var uvNode = this.getNode( node );
+		if ( uvNode === undefined ) {
+
+			// console.log( node.attrName + "(" + node.id + ")" + " has no LayerElementUV." );
+			return [];
+
+		}
+
+		var count = 0;
+		var x = '';
+		for ( var n in uvNode ) {
+
+			if ( n.match( /^\d+$/ ) ) {
+
+				count ++;
+				x = n;
+
+			}
+
+		}
+
+		if ( count > 0 ) {
+
+			console.warn( 'multi uv not supported' );
+			uvNode = uvNode[ n ];
+
+		}
+
+		var uvIndex = uvNode.subNodes.UVIndex.properties.a;
+		var uvs = uvNode.subNodes.UV.properties.a;
+		var uvMap = uvNode.properties.MappingInformationType;
+		var uvRef = uvNode.properties.ReferenceInformationType;
+
+
+		this.uv	= toFloat( uvs.split( ',' ) );
+		this.index = toInt( uvIndex.split( ',' ) );
+
+		this.map = uvMap; // TODO: normalize notation shaking... FOR BLENDER
+		this.ref = uvRef;
+
+		return this.uv;
+
+	};
+
+	UV.prototype.parse = function ( node, geo ) {
+
+		this.uvNode = this.getNode( node );
+
+		this.uv = this.getUV( node );
+		var mappingType = this.getMap( node );
+		var refType = this.getRef( node );
+		var indices = this.getIndex( node );
+
+		var strides = geo.getPolygonTopologyArray();
+
+		// it means that there is a normal for every vertex of every polygon of the model.
+		// For example, if the models has 8 vertices that make up four quads, then there
+		// will be 16 normals (one normal * 4 polygons * 4 vertices of the polygon). Note
+		// that generally a game engine needs the vertices to have only one normal defined.
+		// So, if you find a vertex has more tha one normal, you can either ignore the normals
+		// you find after the first, or calculate the mean from all of them (normal smoothing).
+		//if ( mappingType == "ByPolygonVertex" ){
+		switch ( mappingType ) {
+
+			case "ByPolygonVertex":
+
+				switch ( refType ) {
+
+					// Direct
+					// The this.uv are in order.
+					case "Direct":
+						this.uv = this.parseUV_ByPolygonVertex_Direct( this.uv, indices, strides, 2 );
+						break;
+
+					// IndexToDirect
+					// The order of the this.uv is given by the uvsIndex property.
+					case "IndexToDirect":
+						this.uv = this.parseUV_ByPolygonVertex_IndexToDirect( this.uv, indices );
+						break;
+
+				}
+
+				// convert from by polygon(vert) data into by verts data
+				this.uv = mapByPolygonVertexToByVertex( this.uv, geo.getPolygonVertexIndices( node ), 2 );
+				break;
+
+			case "ByPolygon":
+
+				switch ( refType ) {
+
+					// Direct
+					// The this.uv are in order.
+					case "Direct":
+						this.uv = this.parseUV_ByPolygon_Direct();
+						break;
+
+					// IndexToDirect
+					// The order of the this.uv is given by the uvsIndex property.
+					case "IndexToDirect":
+						this.uv = this.parseUV_ByPolygon_IndexToDirect();
+						break;
+
+				}
+				break;
+		}
+
+		return this.uv;
+
+	};
+
+	UV.prototype.parseUV_ByPolygonVertex_Direct = function ( node, indices, strides, itemSize ) {
+
+		return parse_Data_ByPolygonVertex_Direct( node, indices, strides, itemSize );
+
+	};
+
+	UV.prototype.parseUV_ByPolygonVertex_IndexToDirect = function ( node, indices ) {
+
+		return parse_Data_ByPolygonVertex_IndexToDirect( node, indices, 2 );
+
+	};
+
+	UV.prototype.parseUV_ByPolygon_Direct = function ( node ) {
+
+		console.warn( "not implemented" );
+		return node;
+
+	};
+
+	UV.prototype.parseUV_ByPolygon_IndexToDirect = function ( node ) {
+
+		console.warn( "not implemented" );
+		return node;
+
+	};
+
+	UV.prototype.parseUV_ByVertex_Direct = function ( node ) {
+
+		console.warn( "not implemented" );
+		return node;
+
+	};
+
+
+	function Normal() {
+
+		this.normal = null;
+		this.map	= null;
+		this.ref	= null;
+		this.node = null;
+		this.index = null;
+
+	}
+
+	Normal.prototype.getNormal = function ( node ) {
+
+		if ( this.node && this.normal && this.map && this.ref ) {
+
+			return this.normal;
+
+		} else {
+
+			this._parseText( node );
+			return this.normal;
+
+		}
+
+	};
+
+	// mappingType: possible variant
+	//	  ByPolygon
+	//	  ByPolygonVertex
+	//	  ByVertex (or also ByVertice, as the Blender exporter writes)
+	//	  ByEdge
+	//	  AllSame
+	//	var mappingType = node.properties.MappingInformationType;
+	Normal.prototype.getMap = function ( node ) {
+
+		if ( this.node && this.normal && this.map && this.ref ) {
+
+			return this.map;
+
+		} else {
+
+			this._parseText( node );
+			return this.map;
+
+		}
+
+	};
+
+	// refType: possible variants
+	//	  Direct
+	//	  IndexToDirect (or Index for older versions)
+	// var refType	 = node.properties.ReferenceInformationType;
+	Normal.prototype.getRef = function ( node ) {
+
+		if ( this.node && this.normal && this.map && this.ref ) {
+
+			return this.ref;
+
+		} else {
+
+			this._parseText( node );
+			return this.ref;
+
+		}
+
+	};
+
+	Normal.prototype.getNode = function ( node ) {
+
+		if ( this.node ) {
+
+			return this.node;
+
+		}
+
+		this.node = node.subNodes.LayerElementNormal;
+		return this.node;
+
+	};
+
+	Normal.prototype._parseText = function ( node ) {
+
+		var normalNode = this.getNode( node );
+
+		if ( normalNode === undefined ) {
+
+			console.warn( 'node: ' + node.attrName + "(" + node.id + ") does not have LayerElementNormal" );
+			return;
+
+		}
+
+		var mappingType = normalNode.properties.MappingInformationType;
+		var refType = normalNode.properties.ReferenceInformationType;
+
+		var rawTextNormals = normalNode.subNodes.Normals.properties.a;
+		this.normal = toFloat( rawTextNormals.split( ',' ) );
+
+		// TODO: normalize notation shaking, vertex / vertice... blender...
+		this.map	= mappingType;
+		this.ref	= refType;
+
+	};
+
+	Normal.prototype.parse = function ( topnode, geo ) {
+
+		var normals = this.getNormal( topnode );
+		var normalNode = this.getNode( topnode );
+		var mappingType = this.getMap( topnode );
+		var refType = this.getRef( topnode );
+
+		var indices = geo.getPolygonVertexIndices( topnode );
+		var strides = geo.getPolygonTopologyArray( topnode );
+
+		// it means that there is a normal for every vertex of every polygon of the model.
+		// For example, if the models has 8 vertices that make up four quads, then there
+		// will be 16 normals (one normal * 4 polygons * 4 vertices of the polygon). Note
+		// that generally a game engine needs the vertices to have only one normal defined.
+		// So, if you find a vertex has more tha one normal, you can either ignore the normals
+		// you find after the first, or calculate the mean from all of them (normal smoothing).
+		//if ( mappingType == "ByPolygonVertex" ){
+		switch ( mappingType ) {
+
+			case "ByPolygonVertex":
+
+				switch ( refType ) {
+
+					// Direct
+					// The normals are in order.
+					case "Direct":
+						normals = this.parseNormal_ByPolygonVertex_Direct( normals, indices, strides, 3 );
+						break;
+
+					// IndexToDirect
+					// The order of the normals is given by the NormalsIndex property.
+					case "IndexToDirect":
+						normals = this.parseNormal_ByPolygonVertex_IndexToDirect();
+						break;
+
+				}
+				break;
+
+			case "ByPolygon":
+
+				switch ( refType ) {
+
+					// Direct
+					// The normals are in order.
+					case "Direct":
+						normals = this.parseNormal_ByPolygon_Direct();
+						break;
+
+					// IndexToDirect
+					// The order of the normals is given by the NormalsIndex property.
+					case "IndexToDirect":
+						normals = this.parseNormal_ByPolygon_IndexToDirect();
+						break;
+
+				}
+				break;
+		}
+
+		return normals;
+
+	};
+
+	Normal.prototype.parseNormal_ByPolygonVertex_Direct = function ( node, indices, strides, itemSize ) {
+
+		return parse_Data_ByPolygonVertex_Direct( node, indices, strides, itemSize );
+
+	};
+
+	Normal.prototype.parseNormal_ByPolygonVertex_IndexToDirect = function ( node ) {
+
+		console.warn( "not implemented" );
+		return node;
+
+	};
+
+	Normal.prototype.parseNormal_ByPolygon_Direct = function ( node ) {
+
+		console.warn( "not implemented" );
+		return node;
+
+	};
+
+	Normal.prototype.parseNormal_ByPolygon_IndexToDirect = function ( node ) {
+
+		console.warn( "not implemented" );
+		return node;
+
+	};
+
+	Normal.prototype.parseNormal_ByVertex_Direct = function ( node ) {
+
+		console.warn( "not implemented" );
+		return node;
+
+	};
+
+	function AnimationCurve() {
+
+		this.version = null;
+
+		this.id = null;
+		this.internalId = null;
+		this.times = null;
+		this.values = null;
+
+		this.attrFlag = null; // tangeant
+		this.attrData = null; // slope, weight
+
+	}
+
+	AnimationCurve.prototype.fromNode = function ( curveNode ) {
+
+		this.id = curveNode.id;
+		this.internalId = curveNode.id;
+		this.times = curveNode.subNodes.KeyTime.properties.a;
+		this.values = curveNode.subNodes.KeyValueFloat.properties.a;
+
+		this.attrFlag = curveNode.subNodes.KeyAttrFlags.properties.a;
+		this.attrData = curveNode.subNodes.KeyAttrDataFloat.properties.a;
+
+		this.times = toFloat( this.times.split(	',' ) );
+		this.values = toFloat( this.values.split( ',' ) );
+		this.attrData = toFloat( this.attrData.split( ',' ) );
+		this.attrFlag = toInt( this.attrFlag.split( ',' ) );
+
+		this.times = this.times.map( function ( element ) {
+
+			return FBXTimeToSeconds( element );
+
+		} );
+
+		return this;
+
+	};
+
+	AnimationCurve.prototype.getLength = function () {
+
+		return this.times[ this.times.length - 1 ];
+
+	};
+
+	function AnimationNode() {
+
+		this.id = null;
+		this.attr = null; // S, R, T
+		this.attrX = false;
+		this.attrY = false;
+		this.attrZ = false;
+		this.internalId = null;
+		this.containerInternalId = null; // bone, null etc Id
+		this.containerBoneId = null; // bone, null etc Id
+		this.curveIdx = null; // AnimationCurve's indices
+		this.curves = [];	// AnimationCurve refs
+
+	}
+
+	AnimationNode.prototype.fromNode = function ( allNodes, node, bones ) {
+
+		this.id = node.id;
+		this.attr = node.attrName;
+		this.internalId = node.id;
+
+		if ( this.attr.match( /S|R|T/ ) ) {
+
+			for ( var attrKey in node.properties ) {
+
+				if ( attrKey.match( /X/ ) ) {
+
+					this.attrX = true;
+
+				}
+				if ( attrKey.match( /Y/ ) ) {
+
+					this.attrY = true;
+
+				}
+				if ( attrKey.match( /Z/ ) ) {
+
+					this.attrZ = true;
+
+				}
+
+			}
+
+		} else {
+
+			// may be deform percent nodes
+			return null;
+
+		}
+
+		this.containerIndices = allNodes.searchConnectionParent( this.id );
+		this.curveIdx	= allNodes.searchConnectionChildren( this.id );
+
+		for ( var i = this.containerIndices.length - 1; i >= 0; -- i ) {
+
+			var boneId = bones.searchRealId( this.containerIndices[ i ] );
+			if ( boneId >= 0 ) {
+
+				this.containerBoneId = boneId;
+				this.containerId = this.containerIndices [ i ];
+
+			}
+
+			if ( boneId >= 0 ) {
+
+				break;
+
+			}
+
+		}
+		// this.containerBoneId = bones.searchRealId( this.containerIndices );
+
+		return this;
+
+	};
+
+	AnimationNode.prototype.setCurve = function ( curve ) {
+
+		this.curves.push( curve );
+
+	};
+
+	function Animation() {
+
+		this.curves = {};
+		this.length = 0.0;
+		this.fps	= 30.0;
+		this.frames = 0.0;
+
+	}
+
+	Animation.prototype.parse = function ( node, bones ) {
+
+		var rawNodes = node.Objects.subNodes.AnimationCurveNode;
+		var rawCurves = node.Objects.subNodes.AnimationCurve;
+
+		// first: expand AnimationCurveNode into curve nodes
+		var curveNodes = [];
+		for ( var key in rawNodes ) {
+
+			if ( key.match( /\d+/ ) ) {
+
+				var a = ( new AnimationNode() ).fromNode( node, rawNodes[ key ], bones );
+				curveNodes.push( a );
+
+			}
+
+		}
+
+		// second: gen dict, mapped by internalId
+		var tmp = {};
+		for ( var i = 0; i < curveNodes.length; ++ i ) {
+
+			if ( curveNodes[ i ] === null ) {
+
+				continue;
+
+			}
+
+			tmp[ curveNodes[ i ].id ] = curveNodes[ i ];
+
+		}
+
+		// third: insert curves into the dict
+		var ac = [];
+		var max = 0.0;
+		for ( key in rawCurves ) {
+
+			if ( key.match( /\d+/ ) ) {
+
+				var c = ( new AnimationCurve() ).fromNode( rawCurves[ key ] );
+				ac.push( c );
+				max = c.getLength() ? c.getLength() : max;
+
+				var parentId = node.searchConnectionParent( c.id )[ 0 ];
+				var axis = node.searchConnectionType( c.id, parentId );
+
+				if ( axis.match( /X/ ) ) {
+
+					axis = 'x';
+
+				}
+				if ( axis.match( /Y/ ) ) {
+
+					axis = 'y';
+
+				}
+				if ( axis.match( /Z/ ) ) {
+
+					axis = 'z';
+
+				}
+
+				tmp[ parentId ].curves[ axis ] = c;
+
+			}
+
+		}
+
+		// forth:
+		for ( var t in tmp ) {
+
+			var id = tmp[ t ].containerBoneId;
+			if ( this.curves[ id ] === undefined ) {
+
+				this.curves[ id ] = {};
+
+			}
+
+			this.curves[ id ][ tmp[ t ].attr ] = tmp[ t ];
+
+		}
+
+		this.length = max;
+		this.frames = this.length * this.fps;
+
+		return this;
+
+	};
+
+
+	function Textures() {
+
+		this.textures = [];
+		this.perGeoMap = {};
+
+	}
+
+	Textures.prototype.add = function ( tex ) {
+
+		if ( this.textures === undefined ) {
+
+			this.textures = [];
+
+		}
+
+		this.textures.push( tex );
+
+		for ( var i = 0; i < tex.parentIds.length; ++ i ) {
+
+			if ( this.perGeoMap[ tex.parentIds[ i ] ] === undefined ) {
+
+				this.perGeoMap[ tex.parentIds[ i ] ] = [];
+
+			}
+
+			this.perGeoMap[ tex.parentIds[ i ] ].push( this.textures[ this.textures.length - 1 ] );
+
+		}
+
+	};
+
+	Textures.prototype.parse = function ( node, bones ) {
+
+		var rawNodes = node.Objects.subNodes.Texture;
+
+		for ( var n in rawNodes ) {
+
+			var tex = ( new Texture() ).parse( rawNodes[ n ], node );
+			this.add( tex );
+
+		}
+
+		return this;
+
+	};
+
+	Textures.prototype.getById = function ( id ) {
+
+		return this.perGeoMap[ id ];
+
+	};
+
+	function Texture() {
+
+		this.fileName = "";
+		this.name = "";
+		this.id = null;
+		this.parentIds = [];
+
+	}
+
+	Texture.prototype.parse = function ( node, nodes ) {
+
+		this.id = node.id;
+		this.name = node.attrName;
+		this.fileName = this.parseFileName( node.properties.FileName );
+
+		this.parentIds = this.searchParents( this.id, nodes );
+
+		return this;
+
+	};
+
+	// TODO: support directory
+	Texture.prototype.parseFileName = function ( fname ) {
+
+		if ( fname === undefined ) {
+
+			return "";
+
+		}
+
+		// ignore directory structure, flatten path
+		var splitted = fname.split( /[\\\/]/ );
+		if ( splitted.length > 0 ) {
+
+			return splitted[ splitted.length - 1 ];
+
+		} else {
+
+			return fname;
+
+		}
+
+	};
+
+	Texture.prototype.searchParents = function ( id, nodes ) {
+
+		var p = nodes.searchConnectionParent( id );
+
+		return p;
+
+	};
+
+
+	/* --------------------------------------------------------------------- */
+	/* --------------------------------------------------------------------- */
+	/* --------------------------------------------------------------------- */
+	/* --------------------------------------------------------------------- */
+
+	function loadTextureImage( texture, url ) {
+
+		var loader = new THREE.ImageLoader();
+
+		loader.load( url, function ( image ) {
+
+
+		} );
+
+		loader.load( url, function ( image ) {
+
+			texture.image = image;
+			texture.needUpdate = true;
+			console.log( 'tex load done' );
+
+		},
+
+		// Function called when download progresses
+			function ( xhr ) {
+
+				console.log( ( xhr.loaded / xhr.total * 100 ) + '% loaded' );
+
+			},
+
+			// Function called when download errors
+			function ( xhr ) {
+
+				console.log( 'An error happened' );
+
+			}
+		);
+
+	}
+
+	// LayerElementUV: 0 {
+	// 	Version: 101
+	//	Name: "Texture_Projection"
+	//	MappingInformationType: "ByPolygonVertex"
+	//	ReferenceInformationType: "IndexToDirect"
+	//	UV: *1746 {
+	//	UVIndex: *7068 {
+	//
+	//	The order of the uvs is given by the UVIndex property.
+	function parse_Data_ByPolygonVertex_IndexToDirect( node, indices, itemSize ) {
+
+		var res = [];
+
+		for ( var i = 0; i < indices.length; ++ i ) {
+
+			for ( var j = 0; j < itemSize; ++ j ) {
+
+				res.push( node[ ( indices[ i ] * itemSize ) + j ] );
+
+			}
+
+		}
+
+		return res;
+
+	}
+
+
+	// what want: normal per vertex, order vertice
+	// i have: normal per polygon
+	// i have: indice per polygon
+	parse_Data_ByPolygonVertex_Direct = function ( node, indices, strides, itemSize ) {
+
+		// *21204 > 3573
+		// Geometry: 690680816, "Geometry::", "Mesh" {
+		//  Vertices: *3573 {
+		//  PolygonVertexIndex: *7068 {
+
+		var tmp = [];
+		var currentIndex = 0;
+
+		// first: sort to per vertex
+		for ( var i = 0; i < indices.length; ++ i ) {
+
+			tmp[ indices[ i ] ] = [];
+
+			// TODO: duped entry? blend or something?
+			for ( var s = 0; s < itemSize; ++ s ) {
+
+				tmp[ indices[ i ] ][ s ] = node[ currentIndex + s ];
+
+			}
+
+			currentIndex += itemSize;
+
+		}
+
+		// second: expand x,y,z into serial array
+		var res = [];
+		for ( var jj = 0; jj < tmp.length; ++ jj ) {
+
+			if ( tmp[ jj ] === undefined ) {
+
+				continue;
+
+			}
+
+			for ( var t = 0; t < itemSize; ++ t ) {
+
+				if ( tmp[ jj ][ t ] === undefined ) {
+
+					continue;
+
+				}
+				res.push( tmp[ jj ][ t ] );
+
+			}
+
+		}
+
+		return res;
+
+	};
+
+	// convert from by polygon(vert) data into by verts data
+	function mapByPolygonVertexToByVertex( data, indices, stride ) {
+
+		var tmp = {};
+		var res = [];
+		var max = 0;
+
+		for ( var i = 0; i < indices.length; ++ i ) {
+
+			if ( indices[ i ] in tmp ) {
+
+				continue;
+
+			}
+
+			tmp[ indices[ i ] ] = {};
+
+			for ( var j = 0; j < stride; ++ j ) {
+
+				tmp[ indices[ i ] ][ j ] = data[ i * stride + j ];
+
+			}
+
+			max = max < indices[ i ] ? indices[ i ] : max;
+
+		}
+
+		try {
+
+			for ( i = 0; i <= max; i ++ ) {
+
+				for ( var s = 0; s < stride; s ++ ) {
+
+					res.push( tmp[ i ][ s ] );
+
+				}
+
+			}
+
+		} catch ( e ) {
+			//console.log( max );
+			//console.log( tmp );
+			//console.log( i );
+			//console.log( e );
+		}
+
+		return res;
+
+	}
+
+	// AUTODESK uses broken clock. i guess
+	var FBXTimeToSeconds = function ( adskTime ) {
+
+		return adskTime / 46186158000;
+
+	};
+
+	degToRad = function ( degrees ) {
+
+		return degrees * Math.PI / 180;
+
+	};
+
+	radToDeg = function ( radians ) {
+
+		return radians * 180 / Math.PI;
+
+	};
+
+	quatFromVec = function ( x, y, z ) {
+
+		var euler = new THREE.Euler( x, y, z, 'ZYX' );
+		var quat = new THREE.Quaternion();
+		quat.setFromEuler( euler );
+
+		return quat;
+
+	};
+
+
+	// extend Array.prototype ?  ....uuuh
+	toInt = function ( arr ) {
+
+		return arr.map( function ( element ) {
+
+			return parseInt( element );
+
+		} );
+
+	};
+
+	toFloat = function ( arr ) {
+
+		return arr.map( function ( element ) {
+
+			return parseFloat( element );
+
+		} );
+
+	};
+
+	toRad = function ( arr ) {
+
+		return arr.map( function ( element ) {
+
+			return degToRad( element );
+
+		} );
+
+	};
+
+	toMat44 = function ( arr ) {
+
+		var mat = new THREE.Matrix4();
+		mat.set(
+			arr[ 0 ], arr[ 4 ], arr[ 8 ], arr[ 12 ],
+			arr[ 1 ], arr[ 5 ], arr[ 9 ], arr[ 13 ],
+			arr[ 2 ], arr[ 6 ], arr[ 10 ], arr[ 14 ],
+			arr[ 3 ], arr[ 7 ], arr[ 11 ], arr[ 15 ]
+		);
+
+		/*
+		mat.set(
+			arr[ 0], arr[ 1], arr[ 2], arr[ 3],
+			arr[ 4], arr[ 5], arr[ 6], arr[ 7],
+			arr[ 8], arr[ 9], arr[10], arr[11],
+			arr[12], arr[13], arr[14], arr[15]
+		);
+		// */
+
+		return mat;
+
+	};
 
 } )();