Преглед изворни кода

Merge pull request #16502 from Mugen87/dev32

JSM: More modules and TS files for loaders.
Michael Herzog пре 6 година
родитељ
комит
1c7457a9cb

+ 4 - 0
docs/manual/en/introduction/Import-via-modules.html

@@ -111,12 +111,15 @@
 				</li>
 				<li>loaders
 					<ul>
+						<li>AssimpJSONLoader</li>
+						<li>AssimpLoader</li>
 						<li>BabylonLoader</li>
 						<li>BVHLoader</li>
 						<li>ColladaLoader</li>
 						<li>DDSLoader</li>
 						<li>EXRLoader</li>
 						<li>FBXLoader</li>
+						<li>GCodeLoader</li>
 						<li>GLTFLoader</li>
 						<li>MTLLoader</li>
 						<li>OBJLoader</li>
@@ -124,6 +127,7 @@
 						<li>PDBLoader</li>
 						<li>PlayCanvasLoader</li>
 						<li>PLYLoader</li>
+						<li>RGBELoader</li>
 						<li>STLLoader</li>
 						<li>SVGLoader</li>
 						<li>TGALoader</li>

+ 3 - 1
examples/js/loaders/AssimpLoader.js

@@ -773,8 +773,10 @@ THREE.AssimpLoader.prototype = {
 					mesh = new THREE.Mesh( geometry, mat );
 
 				if ( this.mBones.length > 0 ) {
+
 					mesh = new THREE.SkinnedMesh( geometry, mat );
 					mesh.normalizeSkinWeights();
+
 				}
 
 				this.threeNode = mesh;
@@ -1853,7 +1855,7 @@ THREE.AssimpLoader.prototype = {
 
 				} else {
 
-				// else write as usual
+					// else write as usual
 
 					mesh.mTextureCoords[ n ] = [];
 					//note that assbin always writes 3d texcoords

+ 127 - 122
examples/js/loaders/GCodeLoader.js

@@ -1,5 +1,3 @@
-'use strict';
-
 /**
  * THREE.GCodeLoader is used to load gcode files usually used for 3D printing or CNC applications.
  *
@@ -10,6 +8,7 @@
  * @author tentone
  * @author joewalnes
  */
+
 THREE.GCodeLoader = function ( manager ) {
 
 	this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager;
@@ -18,208 +17,214 @@ THREE.GCodeLoader = function ( manager ) {
 
 };
 
-THREE.GCodeLoader.prototype.load = function ( url, onLoad, onProgress, onError ) {
+THREE.GCodeLoader.prototype = {
 
-	var self = this;
+	constructor: THREE.GCodeLoader,
 
-	var loader = new THREE.FileLoader( self.manager );
-	loader.setPath( self.path );
-	loader.load( url, function ( text ) {
+	load: function ( url, onLoad, onProgress, onError ) {
 
-		onLoad( self.parse( text ) );
+		var self = this;
 
-	}, onProgress, onError );
+		var loader = new THREE.FileLoader( self.manager );
+		loader.setPath( self.path );
+		loader.load( url, function ( text ) {
 
-};
+			onLoad( self.parse( text ) );
 
-THREE.GCodeLoader.prototype.setPath = function ( value ) {
+		}, onProgress, onError );
 
-	this.path = value;
-	return this;
+	},
 
-};
+	setPath: function ( value ) {
 
-THREE.GCodeLoader.prototype.parse = function ( data ) {
+		this.path = value;
+		return this;
 
-	var state = { x: 0, y: 0, z: 0, e: 0, f: 0, extruding: false, relative: false };
-	var layers = [];
+	},
 
-	var currentLayer = undefined;
+	parse: function ( data ) {
 
-	var pathMaterial = new THREE.LineBasicMaterial( { color: 0xFF0000 } );
-	pathMaterial.name = 'path';
+		var state = { x: 0, y: 0, z: 0, e: 0, f: 0, extruding: false, relative: false };
+		var layers = [];
 
-	var extrudingMaterial = new THREE.LineBasicMaterial( { color: 0x00FF00 } );
-	extrudingMaterial.name = 'extruded';
+		var currentLayer = undefined;
 
-	function newLayer( line ) {
+		var pathMaterial = new THREE.LineBasicMaterial( { color: 0xFF0000 } );
+		pathMaterial.name = 'path';
 
-		currentLayer = { vertex: [], pathVertex: [], z: line.z };
-		layers.push( currentLayer );
+		var extrudingMaterial = new THREE.LineBasicMaterial( { color: 0x00FF00 } );
+		extrudingMaterial.name = 'extruded';
 
-	}
+		function newLayer( line ) {
 
-	//Create lie segment between p1 and p2
-	function addSegment( p1, p2 ) {
+			currentLayer = { vertex: [], pathVertex: [], z: line.z };
+			layers.push( currentLayer );
 
-		if ( currentLayer === undefined ) {
+		}
 
-			newLayer( p1 );
+		//Create lie segment between p1 and p2
+		function addSegment( p1, p2 ) {
 
-		}
+			if ( currentLayer === undefined ) {
 
-		if ( line.extruding ) {
+				newLayer( p1 );
 
-			currentLayer.vertex.push( p1.x, p1.y, p1.z );
-			currentLayer.vertex.push( p2.x, p2.y, p2.z );
+			}
 
-		} else {
+			if ( line.extruding ) {
 
-			currentLayer.pathVertex.push( p1.x, p1.y, p1.z );
-			currentLayer.pathVertex.push( p2.x, p2.y, p2.z );
+				currentLayer.vertex.push( p1.x, p1.y, p1.z );
+				currentLayer.vertex.push( p2.x, p2.y, p2.z );
+
+			} else {
+
+				currentLayer.pathVertex.push( p1.x, p1.y, p1.z );
+				currentLayer.pathVertex.push( p2.x, p2.y, p2.z );
+
+			}
 
 		}
 
-	}
+		function delta( v1, v2 ) {
 
-	function delta( v1, v2 ) {
+			return state.relative ? v2 : v2 - v1;
 
-		return state.relative ? v2 : v2 - v1;
+		}
 
-	}
+		function absolute( v1, v2 ) {
 
-	function absolute( v1, v2 ) {
+			return state.relative ? v1 + v2 : v2;
 
-		return state.relative ? v1 + v2 : v2;
+		}
 
-	}
+		var lines = data.replace( /;.+/g, '' ).split( '\n' );
 
-	var lines = data.replace( /;.+/g, '' ).split( '\n' );
+		for ( var i = 0; i < lines.length; i ++ ) {
 
-	for ( var i = 0; i < lines.length; i ++ ) {
+			var tokens = lines[ i ].split( ' ' );
+			var cmd = tokens[ 0 ].toUpperCase();
 
-		var tokens = lines[ i ].split( ' ' );
-		var cmd = tokens[ 0 ].toUpperCase();
+			//Argumments
+			var args = {};
+			tokens.splice( 1 ).forEach( function ( token ) {
 
-		//Argumments
-		var args = {};
-		tokens.splice( 1 ).forEach( function ( token ) {
+				if ( token[ 0 ] !== undefined ) {
 
-			if ( token[ 0 ] !== undefined ) {
+					var key = token[ 0 ].toLowerCase();
+					var value = parseFloat( token.substring( 1 ) );
+					args[ key ] = value;
 
-				var key = token[ 0 ].toLowerCase();
-				var value = parseFloat( token.substring( 1 ) );
-				args[ key ] = value;
+				}
 
-			}
+			} );
 
-		} );
+			//Process commands
+			//G0/G1 – Linear Movement
+			if ( cmd === 'G0' || cmd === 'G1' ) {
 
-		//Process commands
-		//G0/G1 – Linear Movement
-		if ( cmd === 'G0' || cmd === 'G1' ) {
+				var line = {
+					x: args.x !== undefined ? absolute( state.x, args.x ) : state.x,
+					y: args.y !== undefined ? absolute( state.y, args.y ) : state.y,
+					z: args.z !== undefined ? absolute( state.z, args.z ) : state.z,
+					e: args.e !== undefined ? absolute( state.e, args.e ) : state.e,
+					f: args.f !== undefined ? absolute( state.f, args.f ) : state.f,
+				};
 
-			var line = {
-				x: args.x !== undefined ? absolute( state.x, args.x ) : state.x,
-				y: args.y !== undefined ? absolute( state.y, args.y ) : state.y,
-				z: args.z !== undefined ? absolute( state.z, args.z ) : state.z,
-				e: args.e !== undefined ? absolute( state.e, args.e ) : state.e,
-				f: args.f !== undefined ? absolute( state.f, args.f ) : state.f,
-			};
+				//Layer change detection is or made by watching Z, it's made by watching when we extrude at a new Z position
+				if ( delta( state.e, line.e ) > 0 ) {
 
-			//Layer change detection is or made by watching Z, it's made by watching when we extrude at a new Z position
-			if ( delta( state.e, line.e ) > 0 ) {
+					line.extruding = delta( state.e, line.e ) > 0;
 
-				line.extruding = delta( state.e, line.e ) > 0;
+					if ( currentLayer == undefined || line.z != currentLayer.z ) {
 
-				if ( currentLayer == undefined || line.z != currentLayer.z ) {
+						newLayer( line );
 
-					newLayer( line );
+					}
 
 				}
 
-			}
+				addSegment( state, line );
+				state = line;
 
-			addSegment( state, line );
-			state = line;
+			} else if ( cmd === 'G2' || cmd === 'G3' ) {
 
-		} else if ( cmd === 'G2' || cmd === 'G3' ) {
+				//G2/G3 - Arc Movement ( G2 clock wise and G3 counter clock wise )
+				//console.warn( 'THREE.GCodeLoader: Arc command not supported' );
 
-			//G2/G3 - Arc Movement ( G2 clock wise and G3 counter clock wise )
-			//console.warn( 'THREE.GCodeLoader: Arc command not supported' );
+			} else if ( cmd === 'G90' ) {
 
-		} else if ( cmd === 'G90' ) {
+				//G90: Set to Absolute Positioning
+				state.relative = false;
 
-			//G90: Set to Absolute Positioning
-			state.relative = false;
+			} else if ( cmd === 'G91' ) {
 
-		} else if ( cmd === 'G91' ) {
+				//G91: Set to state.relative Positioning
+				state.relative = true;
 
-			//G91: Set to state.relative Positioning
-			state.relative = true;
+			} else if ( cmd === 'G92' ) {
 
-		} else if ( cmd === 'G92' ) {
+				//G92: Set Position
+				var line = state;
+				line.x = args.x !== undefined ? args.x : line.x;
+				line.y = args.y !== undefined ? args.y : line.y;
+				line.z = args.z !== undefined ? args.z : line.z;
+				line.e = args.e !== undefined ? args.e : line.e;
+				state = line;
 
-			//G92: Set Position
-			var line = state;
-			line.x = args.x !== undefined ? args.x : line.x;
-			line.y = args.y !== undefined ? args.y : line.y;
-			line.z = args.z !== undefined ? args.z : line.z;
-			line.e = args.e !== undefined ? args.e : line.e;
-			state = line;
+			} else {
 
-		} else {
+				//console.warn( 'THREE.GCodeLoader: Command not supported:' + cmd );
 
-			//console.warn( 'THREE.GCodeLoader: Command not supported:' + cmd );
+			}
 
 		}
 
-	}
+		function addObject( vertex, extruding ) {
 
-	function addObject( vertex, extruding ) {
+			var geometry = new THREE.BufferGeometry();
+			geometry.addAttribute( 'position', new THREE.Float32BufferAttribute( vertex, 3 ) );
 
-		var geometry = new THREE.BufferGeometry();
-		geometry.addAttribute( 'position', new THREE.Float32BufferAttribute( vertex, 3 ) );
+			var segments = new THREE.LineSegments( geometry, extruding ? extrudingMaterial : pathMaterial );
+			segments.name = 'layer' + i;
+			object.add( segments );
 
-		var segments = new THREE.LineSegments( geometry, extruding ? extrudingMaterial : pathMaterial );
-		segments.name = 'layer' + i;
-		object.add( segments );
+		}
 
-	}
+		var object = new THREE.Group();
+		object.name = 'gcode';
 
-	var object = new THREE.Group();
-	object.name = 'gcode';
+		if ( this.splitLayer ) {
 
-	if ( this.splitLayer ) {
+			for ( var i = 0; i < layers.length; i ++ ) {
 
-		for ( var i = 0; i < layers.length; i ++ ) {
+				var layer = layers[ i ];
+				addObject( layer.vertex, true );
+				addObject( layer.pathVertex, false );
 
-			var layer = layers[ i ];
-			addObject( layer.vertex, true );
-			addObject( layer.pathVertex, false );
+			}
 
-		}
+		} else {
+
+			var vertex = [], pathVertex = [];
 
-	} else {
+			for ( var i = 0; i < layers.length; i ++ ) {
 
-		var vertex = [], pathVertex = [];
+				var layer = layers[ i ];
 
-		for ( var i = 0; i < layers.length; i ++ ) {
+				vertex = vertex.concat( layer.vertex );
+				pathVertex = pathVertex.concat( layer.pathVertex );
 
-			var layer = layers[ i ];
+			}
 
-			vertex = vertex.concat( layer.vertex );
-			pathVertex = pathVertex.concat( layer.pathVertex );
+			addObject( vertex, true );
+			addObject( pathVertex, false );
 
 		}
 
-		addObject( vertex, true );
-		addObject( pathVertex, false );
-
-	}
+		object.quaternion.setFromEuler( new THREE.Euler( - Math.PI / 2, 0, 0 ) );
 
-	object.quaternion.setFromEuler( new THREE.Euler( - Math.PI / 2, 0, 0 ) );
+		return object;
 
-	return object;
+	}
 
 };

+ 2 - 5
examples/js/loaders/RGBELoader.js

@@ -5,7 +5,7 @@
 // https://github.com/mrdoob/three.js/issues/5552
 // http://en.wikipedia.org/wiki/RGBE_image_format
 
-THREE.HDRLoader = THREE.RGBELoader = function ( manager ) {
+THREE.RGBELoader = function ( manager ) {
 
 	this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager;
 	this.type = THREE.UnsignedByteType;
@@ -316,8 +316,7 @@ THREE.RGBELoader.prototype._parser = function ( buffer ) {
 		}
 	;
 
-	var byteArray = new Uint8Array( buffer ),
-		byteLength = byteArray.byteLength;
+	var byteArray = new Uint8Array( buffer );
 	byteArray.pos = 0;
 	var rgbe_header_info = RGBE_ReadHeader( byteArray );
 
@@ -392,5 +391,3 @@ THREE.RGBELoader.prototype.setType = function ( value ) {
 	return this;
 
 };
-
-

+ 18 - 0
examples/jsm/loaders/AssimpJSONLoader.d.ts

@@ -0,0 +1,18 @@
+import {
+  Object3D,
+  LoadingManager
+} from '../../../src/Three';
+
+export class AssimpJSONLoader {
+  constructor(manager?: LoadingManager);
+  manager: LoadingManager;
+  crossOrigin: string;
+  path: string;
+  resourcePath: string;
+
+  load(url: string, onLoad: (object: Object3D) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void) : void;
+  setPath(path: string) : this;
+  setResourcePath(path: string) : this;
+  setCrossOrigin(value: string): this;
+  parse(json: object, path: string) : Object3D;
+}

+ 309 - 0
examples/jsm/loaders/AssimpJSONLoader.js

@@ -0,0 +1,309 @@
+/**
+ * @author Alexander Gessler / http://www.greentoken.de/
+ * https://github.com/acgessler
+ *
+ * Loader for models imported with Open Asset Import Library (http://assimp.sf.net)
+ * through assimp2json (https://github.com/acgessler/assimp2json).
+ *
+ * Supports any input format that assimp supports, including 3ds, obj, dae, blend,
+ * fbx, x, ms3d, lwo (and many more).
+ *
+ * See webgl_loader_assimp2json example.
+ */
+
+import {
+	BufferGeometry,
+	DefaultLoadingManager,
+	FileLoader,
+	Float32BufferAttribute,
+	LoaderUtils,
+	Matrix4,
+	Mesh,
+	MeshPhongMaterial,
+	Object3D,
+	RepeatWrapping,
+	TextureLoader
+} from "../../../build/three.module.js";
+
+var AssimpJSONLoader = function ( manager ) {
+
+	this.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager;
+
+};
+
+AssimpJSONLoader.prototype = {
+
+	constructor: AssimpJSONLoader,
+
+	crossOrigin: 'anonymous',
+
+	load: function ( url, onLoad, onProgress, onError ) {
+
+		var scope = this;
+
+		var path = ( scope.path === undefined ) ? LoaderUtils.extractUrlBase( url ) : scope.path;
+
+		var loader = new FileLoader( this.manager );
+		loader.setPath( scope.path );
+		loader.load( url, function ( text ) {
+
+			var json = JSON.parse( text );
+			var metadata = json.__metadata__;
+
+			// check if __metadata__ meta header is present
+			// this header is used to disambiguate between different JSON-based file formats
+
+			if ( typeof metadata !== 'undefined' ) {
+
+				// check if assimp2json at all
+
+				if ( metadata.format !== 'assimp2json' ) {
+
+					onError( 'THREE.AssimpJSONLoader: Not an assimp2json scene.' );
+					return;
+
+					// check major format version
+
+				} else if ( metadata.version < 100 && metadata.version >= 200 ) {
+
+					onError( 'THREE.AssimpJSONLoader: Unsupported assimp2json file format version.' );
+					return;
+
+				}
+
+			}
+
+			onLoad( scope.parse( json, path ) );
+
+		}, onProgress, onError );
+
+	},
+
+	setPath: function ( value ) {
+
+		this.path = value;
+		return this;
+
+	},
+
+	setResourcePath: function ( value ) {
+
+		this.resourcePath = value;
+		return this;
+
+	},
+
+	setCrossOrigin: function ( value ) {
+
+		this.crossOrigin = value;
+		return this;
+
+	},
+
+	parse: function ( json, path ) {
+
+		function parseList( json, handler ) {
+
+			var meshes = new Array( json.length );
+
+			for ( var i = 0; i < json.length; ++ i ) {
+
+				meshes[ i ] = handler.call( this, json[ i ] );
+
+			}
+
+			return meshes;
+
+		}
+
+		function parseMesh( json ) {
+
+			var geometry = new BufferGeometry();
+
+			var i, l, face;
+
+			var indices = [];
+
+			var vertices = json.vertices || [];
+			var normals = json.normals || [];
+			var uvs = json.texturecoords || [];
+			var colors = json.colors || [];
+
+			uvs = uvs[ 0 ] || []; // only support for a single set of uvs
+
+			for ( i = 0, l = json.faces.length; i < l; i ++ ) {
+
+				face = json.faces[ i ];
+				indices.push( face[ 0 ], face[ 1 ], face[ 2 ] );
+
+			}
+
+			geometry.setIndex( indices );
+			geometry.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
+
+			if ( normals.length > 0 ) {
+
+				geometry.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
+
+			}
+
+			if ( uvs.length > 0 ) {
+
+				geometry.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
+
+			}
+
+			if ( colors.length > 0 ) {
+
+				geometry.addAttribute( 'color', new Float32BufferAttribute( colors, 3 ) );
+
+			}
+
+			geometry.computeBoundingSphere();
+
+			return geometry;
+
+		}
+
+		function parseMaterial( json ) {
+
+			var material = new MeshPhongMaterial();
+
+			for ( var i in json.properties ) {
+
+				var property = json.properties[ i ];
+				var key = property.key;
+				var value = property.value;
+
+				switch ( key ) {
+
+					case '$tex.file': {
+
+						var semantic = property.semantic;
+
+						// prop.semantic gives the type of the texture
+						// 1: diffuse
+						// 2: specular map
+						// 4: emissive map
+						// 5: height map (bumps)
+						// 6: normal map
+						// more values (i.e. environment, etc) are known by assimp and may be relevant
+
+						if ( semantic === 1 || semantic === 2 || semantic === 4 || semantic === 5 || semantic === 6 ) {
+
+							var keyname;
+
+							switch ( semantic ) {
+
+								case 1:
+									keyname = 'map';
+									break;
+								case 2:
+									keyname = 'specularMap';
+									break;
+								case 4:
+									keyname = 'emissiveMap';
+									break;
+								case 5:
+									keyname = 'bumpMap';
+									break;
+								case 6:
+									keyname = 'normalMap';
+									break;
+
+							}
+
+							var texture = textureLoader.load( value );
+
+							// TODO: read texture settings from assimp.
+							// Wrapping is the default, though.
+
+							texture.wrapS = texture.wrapT = RepeatWrapping;
+
+							material[ keyname ] = texture;
+
+						}
+
+						break;
+
+					}
+
+					case '?mat.name':
+						material.name = value;
+						break;
+
+					case '$clr.diffuse':
+						material.color.fromArray( value );
+						break;
+
+					case '$clr.specular':
+						material.specular.fromArray( value );
+						break;
+
+					case '$clr.emissive':
+						material.emissive.fromArray( value );
+						break;
+
+					case '$mat.shininess':
+						material.shininess = value;
+						break;
+
+					case '$mat.shadingm':
+						// aiShadingMode_Flat
+						material.flatShading = ( value === 1 ) ? true : false;
+						break;
+
+					case '$mat.opacity':
+						if ( value < 1 ) {
+
+							material.opacity = value;
+							material.transparent = true;
+
+						}
+						break;
+
+				}
+
+			}
+
+			return material;
+
+		}
+
+		function parseObject( json, node, meshes, materials ) {
+
+			var obj = new Object3D(),	i, idx;
+
+			obj.name = node.name || '';
+			obj.matrix = new Matrix4().fromArray( node.transformation ).transpose();
+			obj.matrix.decompose( obj.position, obj.quaternion, obj.scale );
+
+			for ( i = 0; node.meshes && i < node.meshes.length; i ++ ) {
+
+				idx = node.meshes[ i ];
+				obj.add( new Mesh( meshes[ idx ], materials[ json.meshes[ idx ].materialindex ] ) );
+
+			}
+
+			for ( i = 0; node.children && i < node.children.length; i ++ ) {
+
+				obj.add( parseObject( json, node.children[ i ], meshes, materials ) );
+
+			}
+
+			return obj;
+
+		}
+
+		var textureLoader = new TextureLoader( this.manager );
+		textureLoader.setPath( this.resourcePath || path ).setCrossOrigin( this.crossOrigin );
+
+		var meshes = parseList( json.meshes, parseMesh );
+		var materials = parseList( json.materials, parseMaterial );
+		return parseObject( json, json.rootnode, meshes, materials );
+
+	}
+
+};
+
+export { AssimpJSONLoader };

+ 24 - 0
examples/jsm/loaders/AssimpLoader.d.ts

@@ -0,0 +1,24 @@
+import {
+  Object3D,
+  LoadingManager
+} from '../../../src/Three';
+
+
+export interface Assimp {
+  animation: any;
+  object: Object3D;
+}
+
+export class AssimpLoader {
+  constructor(manager?: LoadingManager);
+  manager: LoadingManager;
+  crossOrigin: string;
+  path: string;
+  resourcePath: string;
+
+  load(url: string, onLoad: (result: Assimp) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void) : void;
+  setPath(path: string) : this;
+  setResourcePath(path: string) : this;
+  setCrossOrigin(value: string): this;
+  parse(buffer: ArrayBuffer, path: string) : Assimp;
+}

+ 2402 - 0
examples/jsm/loaders/AssimpLoader.js

@@ -0,0 +1,2402 @@
+/**
+ * @author Virtulous / https://virtulo.us/
+ */
+
+import {
+	Bone,
+	BufferAttribute,
+	BufferGeometry,
+	Color,
+	DefaultLoadingManager,
+	FileLoader,
+	LoaderUtils,
+	Matrix4,
+	Mesh,
+	MeshLambertMaterial,
+	MeshPhongMaterial,
+	Object3D,
+	Quaternion,
+	Skeleton,
+	SkinnedMesh,
+	TextureLoader,
+	Vector2,
+	Vector3,
+	Vector4
+} from "../../../build/three.module.js";
+
+var AssimpLoader = function ( manager ) {
+
+	this.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager;
+
+};
+
+AssimpLoader.prototype = {
+
+	constructor: AssimpLoader,
+
+	crossOrigin: 'anonymous',
+
+	load: function ( url, onLoad, onProgress, onError ) {
+
+		var scope = this;
+
+		var path = ( scope.path === undefined ) ? LoaderUtils.extractUrlBase( url ) : scope.path;
+
+		var loader = new FileLoader( this.manager );
+		loader.setPath( scope.path );
+		loader.setResponseType( 'arraybuffer' );
+
+		loader.load( url, function ( buffer ) {
+
+			onLoad( scope.parse( buffer, path ) );
+
+		}, onProgress, onError );
+
+	},
+
+	setPath: function ( value ) {
+
+		this.path = value;
+		return this;
+
+	},
+
+	setResourcePath: function ( value ) {
+
+		this.resourcePath = value;
+		return this;
+
+	},
+
+	setCrossOrigin: function ( value ) {
+
+		this.crossOrigin = value;
+		return this;
+
+	},
+
+	parse: function ( buffer, path ) {
+
+		var textureLoader = new TextureLoader( this.manager );
+		textureLoader.setPath( this.resourcePath || path ).setCrossOrigin( this.crossOrigin );
+
+		var Virtulous = {};
+
+		Virtulous.KeyFrame = function ( time, matrix ) {
+
+			this.time = time;
+			this.matrix = matrix.clone();
+			this.position = new Vector3();
+			this.quaternion = new Quaternion();
+			this.scale = new Vector3( 1, 1, 1 );
+			this.matrix.decompose( this.position, this.quaternion, this.scale );
+			this.clone = function () {
+
+				var n = new Virtulous.KeyFrame( this.time, this.matrix );
+				return n;
+
+			};
+			this.lerp = function ( nextKey, time ) {
+
+				time -= this.time;
+				var dist = ( nextKey.time - this.time );
+				var l = time / dist;
+				var l2 = 1 - l;
+				var keypos = this.position;
+				var keyrot = this.quaternion;
+				//      var keyscl =  key.parentspaceScl || key.scl;
+				var key2pos = nextKey.position;
+				var key2rot = nextKey.quaternion;
+				//  var key2scl =  key2.parentspaceScl || key2.scl;
+				Virtulous.KeyFrame.tempAniPos.x = keypos.x * l2 + key2pos.x * l;
+				Virtulous.KeyFrame.tempAniPos.y = keypos.y * l2 + key2pos.y * l;
+				Virtulous.KeyFrame.tempAniPos.z = keypos.z * l2 + key2pos.z * l;
+				//     tempAniScale.x = keyscl[0] * l2 + key2scl[0] * l;
+				//     tempAniScale.y = keyscl[1] * l2 + key2scl[1] * l;
+				//     tempAniScale.z = keyscl[2] * l2 + key2scl[2] * l;
+				Virtulous.KeyFrame.tempAniQuat.set( keyrot.x, keyrot.y, keyrot.z, keyrot.w );
+				Virtulous.KeyFrame.tempAniQuat.slerp( key2rot, l );
+				return Virtulous.KeyFrame.tempAniMatrix.compose( Virtulous.KeyFrame.tempAniPos, Virtulous.KeyFrame.tempAniQuat, Virtulous.KeyFrame.tempAniScale );
+
+			};
+
+		};
+
+		Virtulous.KeyFrame.tempAniPos = new Vector3();
+		Virtulous.KeyFrame.tempAniQuat = new Quaternion();
+		Virtulous.KeyFrame.tempAniScale = new Vector3( 1, 1, 1 );
+		Virtulous.KeyFrame.tempAniMatrix = new Matrix4();
+		Virtulous.KeyFrameTrack = function () {
+
+			this.keys = [];
+			this.target = null;
+			this.time = 0;
+			this.length = 0;
+			this._accelTable = {};
+			this.fps = 20;
+			this.addKey = function ( key ) {
+
+				this.keys.push( key );
+
+			};
+			this.init = function () {
+
+				this.sortKeys();
+
+				if ( this.keys.length > 0 )
+					this.length = this.keys[ this.keys.length - 1 ].time;
+				else
+					this.length = 0;
+
+				if ( ! this.fps ) return;
+
+				for ( var j = 0; j < this.length * this.fps; j ++ ) {
+
+					for ( var i = 0; i < this.keys.length; i ++ ) {
+
+						if ( this.keys[ i ].time == j ) {
+
+							this._accelTable[ j ] = i;
+							break;
+
+						} else if ( this.keys[ i ].time < j / this.fps && this.keys[ i + 1 ] && this.keys[ i + 1 ].time >= j / this.fps ) {
+
+							this._accelTable[ j ] = i;
+							break;
+
+						}
+
+					}
+
+				}
+
+			};
+
+			this.parseFromThree = function ( data ) {
+
+				var fps = data.fps;
+				this.target = data.node;
+				var track = data.hierarchy[ 0 ].keys;
+				for ( var i = 0; i < track.length; i ++ ) {
+
+					this.addKey( new Virtulous.KeyFrame( i / fps || track[ i ].time, track[ i ].targets[ 0 ].data ) );
+
+				}
+				this.init();
+
+			};
+
+			this.parseFromCollada = function ( data ) {
+
+				var track = data.keys;
+				var fps = this.fps;
+
+				for ( var i = 0; i < track.length; i ++ ) {
+
+					this.addKey( new Virtulous.KeyFrame( i / fps || track[ i ].time, track[ i ].matrix ) );
+
+				}
+
+				this.init();
+
+			};
+
+			this.sortKeys = function () {
+
+				this.keys.sort( this.keySortFunc );
+
+			};
+
+			this.keySortFunc = function ( a, b ) {
+
+				return a.time - b.time;
+
+			};
+
+			this.clone = function () {
+
+				var t = new Virtulous.KeyFrameTrack();
+				t.target = this.target;
+				t.time = this.time;
+				t.length = this.length;
+
+				for ( var i = 0; i < this.keys.length; i ++ ) {
+
+					t.addKey( this.keys[ i ].clone() );
+
+				}
+
+				t.init();
+				return t;
+
+			};
+
+			this.reTarget = function ( root, compareitor ) {
+
+				if ( ! compareitor ) compareitor = Virtulous.TrackTargetNodeNameCompare;
+				this.target = compareitor( root, this.target );
+
+			};
+
+			this.keySearchAccel = function ( time ) {
+
+				time *= this.fps;
+				time = Math.floor( time );
+				return this._accelTable[ time ] || 0;
+
+			};
+
+			this.setTime = function ( time ) {
+
+				time = Math.abs( time );
+				if ( this.length )
+					time = time % this.length + .05;
+				var key0 = null;
+				var key1 = null;
+
+				for ( var i = this.keySearchAccel( time ); i < this.keys.length; i ++ ) {
+
+					if ( this.keys[ i ].time == time ) {
+
+						key0 = this.keys[ i ];
+						key1 = this.keys[ i ];
+						break;
+
+					} else if ( this.keys[ i ].time < time && this.keys[ i + 1 ] && this.keys[ i + 1 ].time > time ) {
+
+						key0 = this.keys[ i ];
+						key1 = this.keys[ i + 1 ];
+						break;
+
+					} else if ( this.keys[ i ].time < time && i == this.keys.length - 1 ) {
+
+						key0 = this.keys[ i ];
+						key1 = this.keys[ 0 ].clone();
+						key1.time += this.length + .05;
+						break;
+
+					}
+
+				}
+
+				if ( key0 && key1 && key0 !== key1 ) {
+
+					this.target.matrixAutoUpdate = false;
+					this.target.matrix.copy( key0.lerp( key1, time ) );
+					this.target.matrixWorldNeedsUpdate = true;
+					return;
+
+				}
+
+				if ( key0 && key1 && key0 == key1 ) {
+
+					this.target.matrixAutoUpdate = false;
+					this.target.matrix.copy( key0.matrix );
+					this.target.matrixWorldNeedsUpdate = true;
+					return;
+
+				}
+
+			};
+
+		};
+
+		Virtulous.TrackTargetNodeNameCompare = function ( root, target ) {
+
+			function find( node, name ) {
+
+				if ( node.name == name )
+					return node;
+
+				for ( var i = 0; i < node.children.length; i ++ ) {
+
+					var r = find( node.children[ i ], name );
+					if ( r ) return r;
+
+				}
+
+				return null;
+
+			}
+
+			return find( root, target.name );
+
+		};
+
+		Virtulous.Animation = function () {
+
+			this.tracks = [];
+			this.length = 0;
+
+			this.addTrack = function ( track ) {
+
+				this.tracks.push( track );
+				this.length = Math.max( track.length, this.length );
+
+			};
+
+			this.setTime = function ( time ) {
+
+				this.time = time;
+
+				for ( var i = 0; i < this.tracks.length; i ++ )
+					this.tracks[ i ].setTime( time );
+
+			};
+
+			this.clone = function ( target, compareitor ) {
+
+				if ( ! compareitor ) compareitor = Virtulous.TrackTargetNodeNameCompare;
+				var n = new Virtulous.Animation();
+				n.target = target;
+				for ( var i = 0; i < this.tracks.length; i ++ ) {
+
+					var track = this.tracks[ i ].clone();
+					track.reTarget( target, compareitor );
+					n.addTrack( track );
+
+				}
+
+				return n;
+
+			};
+
+		};
+
+		var ASSBIN_CHUNK_AICAMERA = 0x1234;
+		var ASSBIN_CHUNK_AILIGHT = 0x1235;
+		var ASSBIN_CHUNK_AITEXTURE = 0x1236;
+		var ASSBIN_CHUNK_AIMESH = 0x1237;
+		var ASSBIN_CHUNK_AINODEANIM = 0x1238;
+		var ASSBIN_CHUNK_AISCENE = 0x1239;
+		var ASSBIN_CHUNK_AIBONE = 0x123a;
+		var ASSBIN_CHUNK_AIANIMATION = 0x123b;
+		var ASSBIN_CHUNK_AINODE = 0x123c;
+		var ASSBIN_CHUNK_AIMATERIAL = 0x123d;
+		var ASSBIN_CHUNK_AIMATERIALPROPERTY = 0x123e;
+		var ASSBIN_MESH_HAS_POSITIONS = 0x1;
+		var ASSBIN_MESH_HAS_NORMALS = 0x2;
+		var ASSBIN_MESH_HAS_TANGENTS_AND_BITANGENTS = 0x4;
+		var ASSBIN_MESH_HAS_TEXCOORD_BASE = 0x100;
+		var ASSBIN_MESH_HAS_COLOR_BASE = 0x10000;
+		var AI_MAX_NUMBER_OF_COLOR_SETS = 1;
+		var AI_MAX_NUMBER_OF_TEXTURECOORDS = 4;
+		var aiLightSource_UNDEFINED = 0x0;
+		//! A directional light source has a well-defined direction
+		//! but is infinitely far away. That's quite a good
+		//! approximation for sun light.
+		var aiLightSource_DIRECTIONAL = 0x1;
+		//! A point light source has a well-defined position
+		//! in space but no direction - it emits light in all
+		//! directions. A normal bulb is a point light.
+		var aiLightSource_POINT = 0x2;
+		//! A spot light source emits light in a specific
+		//! angle. It has a position and a direction it is pointing to.
+		//! A good example for a spot light is a light spot in
+		//! sport arenas.
+		var aiLightSource_SPOT = 0x3;
+		//! The generic light level of the world, including the bounces
+		//! of all other lightsources.
+		//! Typically, there's at most one ambient light in a scene.
+		//! This light type doesn't have a valid position, direction, or
+		//! other properties, just a color.
+		var aiLightSource_AMBIENT = 0x4;
+		/** Flat shading. Shading is done on per-face base,
+		 *  diffuse only. Also known as 'faceted shading'.
+		 */
+		var aiShadingMode_Flat = 0x1;
+		/** Simple Gouraud shading.
+		 */
+		var aiShadingMode_Gouraud = 0x2;
+		/** Phong-Shading -
+		 */
+		var aiShadingMode_Phong = 0x3;
+		/** Phong-Blinn-Shading
+		 */
+		var aiShadingMode_Blinn = 0x4;
+		/** Toon-Shading per pixel
+		 *
+		 *  Also known as 'comic' shader.
+		 */
+		var aiShadingMode_Toon = 0x5;
+		/** OrenNayar-Shading per pixel
+		 *
+		 *  Extension to standard Lambertian shading, taking the
+		 *  roughness of the material into account
+		 */
+		var aiShadingMode_OrenNayar = 0x6;
+		/** Minnaert-Shading per pixel
+		 *
+		 *  Extension to standard Lambertian shading, taking the
+		 *  "darkness" of the material into account
+		 */
+		var aiShadingMode_Minnaert = 0x7;
+		/** CookTorrance-Shading per pixel
+		 *
+		 *  Special shader for metallic surfaces.
+		 */
+		var aiShadingMode_CookTorrance = 0x8;
+		/** No shading at all. Constant light influence of 1.0.
+		 */
+		var aiShadingMode_NoShading = 0x9;
+		/** Fresnel shading
+		 */
+		var aiShadingMode_Fresnel = 0xa;
+		var aiTextureType_NONE = 0x0;
+		/** The texture is combined with the result of the diffuse
+		 *  lighting equation.
+		 */
+		var aiTextureType_DIFFUSE = 0x1;
+		/** The texture is combined with the result of the specular
+		 *  lighting equation.
+		 */
+		var aiTextureType_SPECULAR = 0x2;
+		/** The texture is combined with the result of the ambient
+		 *  lighting equation.
+		 */
+		var aiTextureType_AMBIENT = 0x3;
+		/** The texture is added to the result of the lighting
+		 *  calculation. It isn't influenced by incoming light.
+		 */
+		var aiTextureType_EMISSIVE = 0x4;
+		/** The texture is a height map.
+		 *
+		 *  By convention, higher gray-scale values stand for
+		 *  higher elevations from the base height.
+		 */
+		var aiTextureType_HEIGHT = 0x5;
+		/** The texture is a (tangent space) normal-map.
+		 *
+		 *  Again, there are several conventions for tangent-space
+		 *  normal maps. Assimp does (intentionally) not
+		 *  distinguish here.
+		 */
+		var aiTextureType_NORMALS = 0x6;
+		/** The texture defines the glossiness of the material.
+		 *
+		 *  The glossiness is in fact the exponent of the specular
+		 *  (phong) lighting equation. Usually there is a conversion
+		 *  function defined to map the linear color values in the
+		 *  texture to a suitable exponent. Have fun.
+		 */
+		var aiTextureType_SHININESS = 0x7;
+		/** The texture defines per-pixel opacity.
+		 *
+		 *  Usually 'white' means opaque and 'black' means
+		 *  'transparency'. Or quite the opposite. Have fun.
+		 */
+		var aiTextureType_OPACITY = 0x8;
+		/** Displacement texture
+		 *
+		 *  The exact purpose and format is application-dependent.
+		 *  Higher color values stand for higher vertex displacements.
+		 */
+		var aiTextureType_DISPLACEMENT = 0x9;
+		/** Lightmap texture (aka Ambient Occlusion)
+		 *
+		 *  Both 'Lightmaps' and dedicated 'ambient occlusion maps' are
+		 *  covered by this material property. The texture contains a
+		 *  scaling value for the final color value of a pixel. Its
+		 *  intensity is not affected by incoming light.
+		 */
+		var aiTextureType_LIGHTMAP = 0xA;
+		/** Reflection texture
+		 *
+		 * Contains the color of a perfect mirror reflection.
+		 * Rarely used, almost never for real-time applications.
+		 */
+		var aiTextureType_REFLECTION = 0xB;
+		/** Unknown texture
+		 *
+		 *  A texture reference that does not match any of the definitions
+		 *  above is considered to be 'unknown'. It is still imported,
+		 *  but is excluded from any further postprocessing.
+		 */
+		var aiTextureType_UNKNOWN = 0xC;
+		var BONESPERVERT = 4;
+
+		function ASSBIN_MESH_HAS_TEXCOORD( n ) {
+
+			return ASSBIN_MESH_HAS_TEXCOORD_BASE << n;
+
+		}
+
+		function ASSBIN_MESH_HAS_COLOR( n ) {
+
+			return ASSBIN_MESH_HAS_COLOR_BASE << n;
+
+		}
+
+		function markBones( scene ) {
+
+			for ( var i in scene.mMeshes ) {
+
+				var mesh = scene.mMeshes[ i ];
+				for ( var k in mesh.mBones ) {
+
+					var boneNode = scene.findNode( mesh.mBones[ k ].mName );
+					if ( boneNode )
+						boneNode.isBone = true;
+
+				}
+
+			}
+
+		}
+		function cloneTreeToBones( root, scene ) {
+
+			var rootBone = new Bone();
+			rootBone.matrix.copy( root.matrix );
+			rootBone.matrixWorld.copy( root.matrixWorld );
+			rootBone.position.copy( root.position );
+			rootBone.quaternion.copy( root.quaternion );
+			rootBone.scale.copy( root.scale );
+			scene.nodeCount ++;
+			rootBone.name = "bone_" + root.name + scene.nodeCount.toString();
+
+			if ( ! scene.nodeToBoneMap[ root.name ] )
+				scene.nodeToBoneMap[ root.name ] = [];
+			scene.nodeToBoneMap[ root.name ].push( rootBone );
+			for ( var i in root.children ) {
+
+				var child = cloneTreeToBones( root.children[ i ], scene );
+				if ( child )
+					rootBone.add( child );
+
+			}
+
+			return rootBone;
+
+		}
+
+		function sortWeights( indexes, weights ) {
+
+			var pairs = [];
+
+			for ( var i = 0; i < indexes.length; i ++ ) {
+
+				pairs.push( {
+					i: indexes[ i ],
+					w: weights[ i ]
+				} );
+
+			}
+
+			pairs.sort( function ( a, b ) {
+
+				return b.w - a.w;
+
+			 } );
+
+			while ( pairs.length < 4 ) {
+
+				pairs.push( {
+					i: 0,
+					w: 0
+				} );
+
+			}
+
+			if ( pairs.length > 4 )
+				pairs.length = 4;
+			var sum = 0;
+
+			for ( var i = 0; i < 4; i ++ ) {
+
+				sum += pairs[ i ].w * pairs[ i ].w;
+
+			}
+
+			sum = Math.sqrt( sum );
+
+			for ( var i = 0; i < 4; i ++ ) {
+
+				pairs[ i ].w = pairs[ i ].w / sum;
+				indexes[ i ] = pairs[ i ].i;
+				weights[ i ] = pairs[ i ].w;
+
+			}
+
+		}
+
+		function findMatchingBone( root, name ) {
+
+			if ( root.name.indexOf( "bone_" + name ) == 0 )
+				return root;
+
+			for ( var i in root.children ) {
+
+				var ret = findMatchingBone( root.children[ i ], name );
+
+				if ( ret )
+					return ret;
+
+			}
+
+			return undefined;
+
+		}
+
+		function aiMesh() {
+
+			this.mPrimitiveTypes = 0;
+			this.mNumVertices = 0;
+			this.mNumFaces = 0;
+			this.mNumBones = 0;
+			this.mMaterialIndex = 0;
+			this.mVertices = [];
+			this.mNormals = [];
+			this.mTangents = [];
+			this.mBitangents = [];
+			this.mColors = [
+				[]
+			];
+			this.mTextureCoords = [
+				[]
+			];
+			this.mFaces = [];
+			this.mBones = [];
+			this.hookupSkeletons = function ( scene, threeScene ) {
+
+				if ( this.mBones.length == 0 ) return;
+
+				var allBones = [];
+				var offsetMatrix = [];
+				var skeletonRoot = scene.findNode( this.mBones[ 0 ].mName );
+
+				while ( skeletonRoot.mParent && skeletonRoot.mParent.isBone ) {
+
+					skeletonRoot = skeletonRoot.mParent;
+
+				}
+
+				var threeSkeletonRoot = skeletonRoot.toTHREE( scene );
+				var threeSkeletonRootBone = cloneTreeToBones( threeSkeletonRoot, scene );
+				this.threeNode.add( threeSkeletonRootBone );
+
+				for ( var i = 0; i < this.mBones.length; i ++ ) {
+
+					var bone = findMatchingBone( threeSkeletonRootBone, this.mBones[ i ].mName );
+
+					if ( bone ) {
+
+						var tbone = bone;
+						allBones.push( tbone );
+						//tbone.matrixAutoUpdate = false;
+						offsetMatrix.push( this.mBones[ i ].mOffsetMatrix.toTHREE() );
+
+					} else {
+
+						var skeletonRoot = scene.findNode( this.mBones[ i ].mName );
+						if ( ! skeletonRoot ) return;
+						var threeSkeletonRoot = skeletonRoot.toTHREE( scene );
+						var threeSkeletonRootParent = threeSkeletonRoot.parent;
+						var threeSkeletonRootBone = cloneTreeToBones( threeSkeletonRoot, scene );
+						this.threeNode.add( threeSkeletonRootBone );
+						var bone = findMatchingBone( threeSkeletonRootBone, this.mBones[ i ].mName );
+						var tbone = bone;
+						allBones.push( tbone );
+						//tbone.matrixAutoUpdate = false;
+						offsetMatrix.push( this.mBones[ i ].mOffsetMatrix.toTHREE() );
+
+					}
+
+				}
+				var skeleton = new Skeleton( allBones, offsetMatrix );
+
+				this.threeNode.bind( skeleton, new Matrix4() );
+				this.threeNode.material.skinning = true;
+
+			};
+
+			this.toTHREE = function ( scene ) {
+
+				if ( this.threeNode ) return this.threeNode;
+				var geometry = new BufferGeometry();
+				var mat;
+				if ( scene.mMaterials[ this.mMaterialIndex ] )
+					mat = scene.mMaterials[ this.mMaterialIndex ].toTHREE( scene );
+				else
+					mat = new MeshLambertMaterial();
+				geometry.setIndex( new BufferAttribute( new Uint32Array( this.mIndexArray ), 1 ) );
+				geometry.addAttribute( 'position', new BufferAttribute( this.mVertexBuffer, 3 ) );
+				if ( this.mNormalBuffer && this.mNormalBuffer.length > 0 )
+					geometry.addAttribute( 'normal', new BufferAttribute( this.mNormalBuffer, 3 ) );
+				if ( this.mColorBuffer && this.mColorBuffer.length > 0 )
+					geometry.addAttribute( 'color', new BufferAttribute( this.mColorBuffer, 4 ) );
+				if ( this.mTexCoordsBuffers[ 0 ] && this.mTexCoordsBuffers[ 0 ].length > 0 )
+					geometry.addAttribute( 'uv', new BufferAttribute( new Float32Array( this.mTexCoordsBuffers[ 0 ] ), 2 ) );
+				if ( this.mTexCoordsBuffers[ 1 ] && this.mTexCoordsBuffers[ 1 ].length > 0 )
+					geometry.addAttribute( 'uv1', new BufferAttribute( new Float32Array( this.mTexCoordsBuffers[ 1 ] ), 2 ) );
+				if ( this.mTangentBuffer && this.mTangentBuffer.length > 0 )
+					geometry.addAttribute( 'tangents', new BufferAttribute( this.mTangentBuffer, 3 ) );
+				if ( this.mBitangentBuffer && this.mBitangentBuffer.length > 0 )
+					geometry.addAttribute( 'bitangents', new BufferAttribute( this.mBitangentBuffer, 3 ) );
+				if ( this.mBones.length > 0 ) {
+
+					var weights = [];
+					var bones = [];
+
+					for ( var i = 0; i < this.mBones.length; i ++ ) {
+
+						for ( var j = 0; j < this.mBones[ i ].mWeights.length; j ++ ) {
+
+							var weight = this.mBones[ i ].mWeights[ j ];
+							if ( weight ) {
+
+								if ( ! weights[ weight.mVertexId ] ) weights[ weight.mVertexId ] = [];
+								if ( ! bones[ weight.mVertexId ] ) bones[ weight.mVertexId ] = [];
+								weights[ weight.mVertexId ].push( weight.mWeight );
+								bones[ weight.mVertexId ].push( parseInt( i ) );
+
+							}
+
+						}
+
+					}
+
+					for ( var i in bones ) {
+
+						sortWeights( bones[ i ], weights[ i ] );
+
+					}
+
+					var _weights = [];
+					var _bones = [];
+
+					for ( var i = 0; i < weights.length; i ++ ) {
+
+						for ( var j = 0; j < 4; j ++ ) {
+
+							if ( weights[ i ] && bones[ i ] ) {
+
+								_weights.push( weights[ i ][ j ] );
+								_bones.push( bones[ i ][ j ] );
+
+							} else {
+
+								_weights.push( 0 );
+								_bones.push( 0 );
+
+							}
+
+						}
+
+					}
+
+					geometry.addAttribute( 'skinWeight', new BufferAttribute( new Float32Array( _weights ), BONESPERVERT ) );
+					geometry.addAttribute( 'skinIndex', new BufferAttribute( new Float32Array( _bones ), BONESPERVERT ) );
+
+				}
+
+				var mesh;
+
+				if ( this.mBones.length == 0 )
+					mesh = new Mesh( geometry, mat );
+
+				if ( this.mBones.length > 0 ) {
+
+					mesh = new SkinnedMesh( geometry, mat );
+					mesh.normalizeSkinWeights();
+
+				}
+
+				this.threeNode = mesh;
+				//mesh.matrixAutoUpdate = false;
+				return mesh;
+
+			};
+
+		}
+
+		function aiFace() {
+
+			this.mNumIndices = 0;
+			this.mIndices = [];
+
+		}
+
+		function aiVector3D() {
+
+			this.x = 0;
+			this.y = 0;
+			this.z = 0;
+
+			this.toTHREE = function () {
+
+				return new Vector3( this.x, this.y, this.z );
+
+			};
+
+		}
+
+		function aiVector2D() {
+
+			this.x = 0;
+			this.y = 0;
+			this.toTHREE = function () {
+
+				return new Vector2( this.x, this.y );
+
+			};
+
+		}
+
+		function aiVector4D() {
+
+			this.w = 0;
+			this.x = 0;
+			this.y = 0;
+			this.z = 0;
+			this.toTHREE = function () {
+
+				return new Vector4( this.w, this.x, this.y, this.z );
+
+			};
+
+		}
+
+		function aiColor4D() {
+
+			this.r = 0;
+			this.g = 0;
+			this.b = 0;
+			this.a = 0;
+			this.toTHREE = function () {
+
+				return new Color( this.r, this.g, this.b, this.a );
+
+			};
+
+		}
+
+		function aiColor3D() {
+
+			this.r = 0;
+			this.g = 0;
+			this.b = 0;
+			this.a = 0;
+			this.toTHREE = function () {
+
+				return new Color( this.r, this.g, this.b, 1 );
+
+			};
+
+		}
+
+		function aiQuaternion() {
+
+			this.x = 0;
+			this.y = 0;
+			this.z = 0;
+			this.w = 0;
+			this.toTHREE = function () {
+
+				return new Quaternion( this.x, this.y, this.z, this.w );
+
+			};
+
+		}
+
+		function aiVertexWeight() {
+
+			this.mVertexId = 0;
+			this.mWeight = 0;
+
+		}
+
+		function aiString() {
+
+			this.data = [];
+			this.toString = function () {
+
+				var str = '';
+				this.data.forEach( function ( i ) {
+
+					str += ( String.fromCharCode( i ) );
+
+				} );
+				return str.replace( /[^\x20-\x7E]+/g, '' );
+
+			};
+
+		}
+
+		function aiVectorKey() {
+
+			this.mTime = 0;
+			this.mValue = null;
+
+		}
+
+		function aiQuatKey() {
+
+			this.mTime = 0;
+			this.mValue = null;
+
+		}
+
+		function aiNode() {
+
+			this.mName = '';
+			this.mTransformation = [];
+			this.mNumChildren = 0;
+			this.mNumMeshes = 0;
+			this.mMeshes = [];
+			this.mChildren = [];
+			this.toTHREE = function ( scene ) {
+
+				if ( this.threeNode ) return this.threeNode;
+				var o = new Object3D();
+				o.name = this.mName;
+				o.matrix = this.mTransformation.toTHREE();
+
+				for ( var i = 0; i < this.mChildren.length; i ++ ) {
+
+					o.add( this.mChildren[ i ].toTHREE( scene ) );
+
+				}
+
+				for ( var i = 0; i < this.mMeshes.length; i ++ ) {
+
+					o.add( scene.mMeshes[ this.mMeshes[ i ] ].toTHREE( scene ) );
+
+				}
+
+				this.threeNode = o;
+				//o.matrixAutoUpdate = false;
+				o.matrix.decompose( o.position, o.quaternion, o.scale );
+				return o;
+
+			};
+
+		}
+
+		function aiBone() {
+
+			this.mName = '';
+			this.mNumWeights = 0;
+			this.mOffsetMatrix = 0;
+
+		}
+
+		function aiMaterialProperty() {
+
+			this.mKey = "";
+			this.mSemantic = 0;
+			this.mIndex = 0;
+			this.mData = [];
+			this.mDataLength = 0;
+			this.mType = 0;
+			this.dataAsColor = function () {
+
+				var array = ( new Uint8Array( this.mData ) ).buffer;
+				var reader = new DataView( array );
+				var r = reader.getFloat32( 0, true );
+				var g = reader.getFloat32( 4, true );
+				var b = reader.getFloat32( 8, true );
+				//var a = reader.getFloat32(12, true);
+				return new Color( r, g, b );
+
+			};
+
+			this.dataAsFloat = function () {
+
+				var array = ( new Uint8Array( this.mData ) ).buffer;
+				var reader = new DataView( array );
+				var r = reader.getFloat32( 0, true );
+				return r;
+
+			};
+
+			this.dataAsBool = function () {
+
+				var array = ( new Uint8Array( this.mData ) ).buffer;
+				var reader = new DataView( array );
+				var r = reader.getFloat32( 0, true );
+				return !! r;
+
+			};
+
+			this.dataAsString = function () {
+
+				var s = new aiString();
+				s.data = this.mData;
+				return s.toString();
+
+			};
+
+			this.dataAsMap = function () {
+
+				var s = new aiString();
+				s.data = this.mData;
+				var path = s.toString();
+				path = path.replace( /\\/g, '/' );
+
+				if ( path.indexOf( '/' ) != - 1 ) {
+
+					path = path.substr( path.lastIndexOf( '/' ) + 1 );
+
+				}
+
+				return textureLoader.load( path );
+
+			};
+
+		}
+		var namePropMapping = {
+
+			"?mat.name": "name",
+			"$mat.shadingm": "shading",
+			"$mat.twosided": "twoSided",
+			"$mat.wireframe": "wireframe",
+			"$clr.ambient": "ambient",
+			"$clr.diffuse": "color",
+			"$clr.specular": "specular",
+			"$clr.emissive": "emissive",
+			"$clr.transparent": "transparent",
+			"$clr.reflective": "reflect",
+			"$mat.shininess": "shininess",
+			"$mat.reflectivity": "reflectivity",
+			"$mat.refracti": "refraction",
+			"$tex.file": "map"
+
+		};
+
+		var nameTypeMapping = {
+
+			"?mat.name": "string",
+			"$mat.shadingm": "bool",
+			"$mat.twosided": "bool",
+			"$mat.wireframe": "bool",
+			"$clr.ambient": "color",
+			"$clr.diffuse": "color",
+			"$clr.specular": "color",
+			"$clr.emissive": "color",
+			"$clr.transparent": "color",
+			"$clr.reflective": "color",
+			"$mat.shininess": "float",
+			"$mat.reflectivity": "float",
+			"$mat.refracti": "float",
+			"$tex.file": "map"
+
+		};
+
+		function aiMaterial() {
+
+			this.mNumAllocated = 0;
+			this.mNumProperties = 0;
+			this.mProperties = [];
+			this.toTHREE = function ( scene ) {
+
+				var name = this.mProperties[ 0 ].dataAsString();
+				var mat = new MeshPhongMaterial();
+
+				for ( var i = 0; i < this.mProperties.length; i ++ ) {
+
+					if ( nameTypeMapping[ this.mProperties[ i ].mKey ] == 'float' )
+						mat[ namePropMapping[ this.mProperties[ i ].mKey ] ] = this.mProperties[ i ].dataAsFloat();
+					if ( nameTypeMapping[ this.mProperties[ i ].mKey ] == 'color' )
+						mat[ namePropMapping[ this.mProperties[ i ].mKey ] ] = this.mProperties[ i ].dataAsColor();
+					if ( nameTypeMapping[ this.mProperties[ i ].mKey ] == 'bool' )
+						mat[ namePropMapping[ this.mProperties[ i ].mKey ] ] = this.mProperties[ i ].dataAsBool();
+					if ( nameTypeMapping[ this.mProperties[ i ].mKey ] == 'string' )
+						mat[ namePropMapping[ this.mProperties[ i ].mKey ] ] = this.mProperties[ i ].dataAsString();
+					if ( nameTypeMapping[ this.mProperties[ i ].mKey ] == 'map' ) {
+
+						var prop = this.mProperties[ i ];
+						if ( prop.mSemantic == aiTextureType_DIFFUSE )
+							mat.map = this.mProperties[ i ].dataAsMap();
+						if ( prop.mSemantic == aiTextureType_NORMALS )
+							mat.normalMap = this.mProperties[ i ].dataAsMap();
+						if ( prop.mSemantic == aiTextureType_LIGHTMAP )
+							mat.lightMap = this.mProperties[ i ].dataAsMap();
+						if ( prop.mSemantic == aiTextureType_OPACITY )
+							mat.alphaMap = this.mProperties[ i ].dataAsMap();
+
+					}
+
+				}
+
+				mat.ambient.r = .53;
+				mat.ambient.g = .53;
+				mat.ambient.b = .53;
+				mat.color.r = 1;
+				mat.color.g = 1;
+				mat.color.b = 1;
+				return mat;
+
+			};
+
+		}
+
+
+		function veclerp( v1, v2, l ) {
+
+			var v = new Vector3();
+			var lm1 = 1 - l;
+			v.x = v1.x * l + v2.x * lm1;
+			v.y = v1.y * l + v2.y * lm1;
+			v.z = v1.z * l + v2.z * lm1;
+			return v;
+
+		}
+
+		function quatlerp( q1, q2, l ) {
+
+			return q1.clone().slerp( q2, 1 - l );
+
+		}
+
+		function sampleTrack( keys, time, lne, lerp ) {
+
+			if ( keys.length == 1 ) return keys[ 0 ].mValue.toTHREE();
+
+			var dist = Infinity;
+			var key = null;
+			var nextKey = null;
+
+			for ( var i = 0; i < keys.length; i ++ ) {
+
+				var timeDist = Math.abs( keys[ i ].mTime - time );
+
+				if ( timeDist < dist && keys[ i ].mTime <= time ) {
+
+					dist = timeDist;
+					key = keys[ i ];
+					nextKey = keys[ i + 1 ];
+
+				}
+
+			}
+
+			if ( ! key ) {
+
+				return null;
+
+			} else if ( nextKey ) {
+
+				var dT = nextKey.mTime - key.mTime;
+				var T = key.mTime - time;
+				var l = T / dT;
+
+				return lerp( key.mValue.toTHREE(), nextKey.mValue.toTHREE(), l );
+
+			} else {
+
+				nextKey = keys[ 0 ].clone();
+				nextKey.mTime += lne;
+
+				var dT = nextKey.mTime - key.mTime;
+				var T = key.mTime - time;
+				var l = T / dT;
+
+				return lerp( key.mValue.toTHREE(), nextKey.mValue.toTHREE(), l );
+
+			}
+
+		}
+
+		function aiNodeAnim() {
+
+			this.mNodeName = "";
+			this.mNumPositionKeys = 0;
+			this.mNumRotationKeys = 0;
+			this.mNumScalingKeys = 0;
+			this.mPositionKeys = [];
+			this.mRotationKeys = [];
+			this.mScalingKeys = [];
+			this.mPreState = "";
+			this.mPostState = "";
+			this.init = function ( tps ) {
+
+				if ( ! tps ) tps = 1;
+
+				function t( t ) {
+
+					t.mTime /= tps;
+
+				}
+
+				this.mPositionKeys.forEach( t );
+				this.mRotationKeys.forEach( t );
+				this.mScalingKeys.forEach( t );
+
+			};
+
+			this.sortKeys = function () {
+
+				function comp( a, b ) {
+
+					return a.mTime - b.mTime;
+
+				}
+
+				this.mPositionKeys.sort( comp );
+				this.mRotationKeys.sort( comp );
+				this.mScalingKeys.sort( comp );
+
+			};
+
+			this.getLength = function () {
+
+				return Math.max(
+					Math.max.apply( null, this.mPositionKeys.map( function ( a ) {
+
+						return a.mTime;
+
+					} ) ),
+					Math.max.apply( null, this.mRotationKeys.map( function ( a ) {
+
+						return a.mTime;
+
+					} ) ),
+					Math.max.apply( null, this.mScalingKeys.map( function ( a ) {
+
+						return a.mTime;
+
+				 } ) )
+				);
+
+			};
+
+			this.toTHREE = function ( o, tps ) {
+
+				this.sortKeys();
+				var length = this.getLength();
+				var track = new Virtulous.KeyFrameTrack();
+
+				for ( var i = 0; i < length; i += .05 ) {
+
+					var matrix = new Matrix4();
+					var time = i;
+					var pos = sampleTrack( this.mPositionKeys, time, length, veclerp );
+					var scale = sampleTrack( this.mScalingKeys, time, length, veclerp );
+					var rotation = sampleTrack( this.mRotationKeys, time, length, quatlerp );
+					matrix.compose( pos, rotation, scale );
+
+					var key = new Virtulous.KeyFrame( time, matrix );
+					track.addKey( key );
+
+				}
+
+				track.target = o.findNode( this.mNodeName ).toTHREE();
+
+				var tracks = [ track ];
+
+				if ( o.nodeToBoneMap[ this.mNodeName ] ) {
+
+					for ( var i = 0; i < o.nodeToBoneMap[ this.mNodeName ].length; i ++ ) {
+
+						var t2 = track.clone();
+						t2.target = o.nodeToBoneMap[ this.mNodeName ][ i ];
+						tracks.push( t2 );
+
+					}
+
+				}
+
+				return tracks;
+
+			};
+
+		}
+
+		function aiAnimation() {
+
+			this.mName = "";
+			this.mDuration = 0;
+			this.mTicksPerSecond = 0;
+			this.mNumChannels = 0;
+			this.mChannels = [];
+			this.toTHREE = function ( root ) {
+
+				var animationHandle = new Virtulous.Animation();
+
+				for ( var i in this.mChannels ) {
+
+					this.mChannels[ i ].init( this.mTicksPerSecond );
+
+					var tracks = this.mChannels[ i ].toTHREE( root );
+
+					for ( var j in tracks ) {
+
+						tracks[ j ].init();
+						animationHandle.addTrack( tracks[ j ] );
+
+					}
+
+				}
+
+				animationHandle.length = Math.max.apply( null, animationHandle.tracks.map( function ( e ) {
+
+					return e.length;
+
+				} ) );
+				return animationHandle;
+
+			};
+
+		}
+
+		function aiTexture() {
+
+			this.mWidth = 0;
+			this.mHeight = 0;
+			this.texAchFormatHint = [];
+			this.pcData = [];
+
+		}
+
+		function aiLight() {
+
+			this.mName = '';
+			this.mType = 0;
+			this.mAttenuationConstant = 0;
+			this.mAttenuationLinear = 0;
+			this.mAttenuationQuadratic = 0;
+			this.mAngleInnerCone = 0;
+			this.mAngleOuterCone = 0;
+			this.mColorDiffuse = null;
+			this.mColorSpecular = null;
+			this.mColorAmbient = null;
+
+		}
+
+		function aiCamera() {
+
+			this.mName = '';
+			this.mPosition = null;
+			this.mLookAt = null;
+			this.mUp = null;
+			this.mHorizontalFOV = 0;
+			this.mClipPlaneNear = 0;
+			this.mClipPlaneFar = 0;
+			this.mAspect = 0;
+
+		}
+
+		function aiScene() {
+
+			this.mFlags = 0;
+			this.mNumMeshes = 0;
+			this.mNumMaterials = 0;
+			this.mNumAnimations = 0;
+			this.mNumTextures = 0;
+			this.mNumLights = 0;
+			this.mNumCameras = 0;
+			this.mRootNode = null;
+			this.mMeshes = [];
+			this.mMaterials = [];
+			this.mAnimations = [];
+			this.mLights = [];
+			this.mCameras = [];
+			this.nodeToBoneMap = {};
+			this.findNode = function ( name, root ) {
+
+				if ( ! root ) {
+
+					root = this.mRootNode;
+
+				}
+
+				if ( root.mName == name ) {
+
+					return root;
+
+				}
+
+				for ( var i = 0; i < root.mChildren.length; i ++ ) {
+
+					var ret = this.findNode( name, root.mChildren[ i ] );
+					if ( ret ) return ret;
+
+				}
+
+				return null;
+
+			};
+
+			this.toTHREE = function () {
+
+				this.nodeCount = 0;
+
+				markBones( this );
+
+				var o = this.mRootNode.toTHREE( this );
+
+				for ( var i in this.mMeshes )
+					this.mMeshes[ i ].hookupSkeletons( this, o );
+
+				if ( this.mAnimations.length > 0 ) {
+
+					var a = this.mAnimations[ 0 ].toTHREE( this );
+
+				}
+
+				return { object: o, animation: a };
+
+			};
+
+		}
+
+		function aiMatrix4() {
+
+			this.elements = [
+				[],
+				[],
+				[],
+				[]
+			];
+			this.toTHREE = function () {
+
+				var m = new Matrix4();
+
+				for ( var i = 0; i < 4; ++ i ) {
+
+					for ( var i2 = 0; i2 < 4; ++ i2 ) {
+
+						m.elements[ i * 4 + i2 ] = this.elements[ i2 ][ i ];
+
+					}
+
+				}
+
+				return m;
+
+			};
+
+		}
+
+		var littleEndian = true;
+
+		function readFloat( dataview ) {
+
+			var val = dataview.getFloat32( dataview.readOffset, littleEndian );
+			dataview.readOffset += 4;
+			return val;
+
+		}
+
+		function Read_double( dataview ) {
+
+			var val = dataview.getFloat64( dataview.readOffset, littleEndian );
+			dataview.readOffset += 8;
+			return val;
+
+		}
+
+		function Read_uint8_t( dataview ) {
+
+			var val = dataview.getUint8( dataview.readOffset );
+			dataview.readOffset += 1;
+			return val;
+
+		}
+
+		function Read_uint16_t( dataview ) {
+
+			var val = dataview.getUint16( dataview.readOffset, littleEndian );
+			dataview.readOffset += 2;
+			return val;
+
+		}
+
+		function Read_unsigned_int( dataview ) {
+
+			var val = dataview.getUint32( dataview.readOffset, littleEndian );
+			dataview.readOffset += 4;
+			return val;
+
+		}
+
+		function Read_uint32_t( dataview ) {
+
+			var val = dataview.getUint32( dataview.readOffset, littleEndian );
+			dataview.readOffset += 4;
+			return val;
+
+		}
+
+		function Read_aiVector3D( stream ) {
+
+			var v = new aiVector3D();
+			v.x = readFloat( stream );
+			v.y = readFloat( stream );
+			v.z = readFloat( stream );
+			return v;
+
+		}
+
+		function Read_aiVector2D( stream ) {
+
+			var v = new aiVector2D();
+			v.x = readFloat( stream );
+			v.y = readFloat( stream );
+			return v;
+
+		}
+
+		function Read_aiVector4D( stream ) {
+
+			var v = new aiVector4D();
+			v.w = readFloat( stream );
+			v.x = readFloat( stream );
+			v.y = readFloat( stream );
+			v.z = readFloat( stream );
+			return v;
+
+		}
+
+		function Read_aiColor3D( stream ) {
+
+			var c = new aiColor3D();
+			c.r = readFloat( stream );
+			c.g = readFloat( stream );
+			c.b = readFloat( stream );
+			return c;
+
+		}
+
+		function Read_aiColor4D( stream ) {
+
+			var c = new aiColor4D();
+			c.r = readFloat( stream );
+			c.g = readFloat( stream );
+			c.b = readFloat( stream );
+			c.a = readFloat( stream );
+			return c;
+
+		}
+
+		function Read_aiQuaternion( stream ) {
+
+			var v = new aiQuaternion();
+			v.w = readFloat( stream );
+			v.x = readFloat( stream );
+			v.y = readFloat( stream );
+			v.z = readFloat( stream );
+			return v;
+
+		}
+
+		function Read_aiString( stream ) {
+
+			var s = new aiString();
+			var stringlengthbytes = Read_unsigned_int( stream );
+			stream.ReadBytes( s.data, 1, stringlengthbytes );
+			return s.toString();
+
+		}
+
+		function Read_aiVertexWeight( stream ) {
+
+			var w = new aiVertexWeight();
+			w.mVertexId = Read_unsigned_int( stream );
+			w.mWeight = readFloat( stream );
+			return w;
+
+		}
+
+		function Read_aiMatrix4x4( stream ) {
+
+			var m = new aiMatrix4();
+
+			for ( var i = 0; i < 4; ++ i ) {
+
+				for ( var i2 = 0; i2 < 4; ++ i2 ) {
+
+					m.elements[ i ][ i2 ] = readFloat( stream );
+
+				}
+
+			}
+
+			return m;
+
+		}
+
+		function Read_aiVectorKey( stream ) {
+
+			var v = new aiVectorKey();
+			v.mTime = Read_double( stream );
+			v.mValue = Read_aiVector3D( stream );
+			return v;
+
+		}
+
+		function Read_aiQuatKey( stream ) {
+
+			var v = new aiQuatKey();
+			v.mTime = Read_double( stream );
+			v.mValue = Read_aiQuaternion( stream );
+			return v;
+
+		}
+
+		function ReadArray( stream, data, size ) {
+
+			for ( var i = 0; i < size; i ++ ) data[ i ] = Read( stream );
+
+		}
+
+		function ReadArray_aiVector2D( stream, data, size ) {
+
+			for ( var i = 0; i < size; i ++ ) data[ i ] = Read_aiVector2D( stream );
+
+		}
+
+		function ReadArray_aiVector3D( stream, data, size ) {
+
+			for ( var i = 0; i < size; i ++ ) data[ i ] = Read_aiVector3D( stream );
+
+		}
+
+		function ReadArray_aiVector4D( stream, data, size ) {
+
+			for ( var i = 0; i < size; i ++ ) data[ i ] = Read_aiVector4D( stream );
+
+		}
+
+		function ReadArray_aiVertexWeight( stream, data, size ) {
+
+			for ( var i = 0; i < size; i ++ ) data[ i ] = Read_aiVertexWeight( stream );
+
+		}
+
+		function ReadArray_aiColor4D( stream, data, size ) {
+
+			for ( var i = 0; i < size; i ++ ) data[ i ] = Read_aiColor4D( stream );
+
+		}
+
+		function ReadArray_aiVectorKey( stream, data, size ) {
+
+			for ( var i = 0; i < size; i ++ ) data[ i ] = Read_aiVectorKey( stream );
+
+		}
+
+		function ReadArray_aiQuatKey( stream, data, size ) {
+
+			for ( var i = 0; i < size; i ++ ) data[ i ] = Read_aiQuatKey( stream );
+
+		}
+
+		function ReadBounds( stream, T /*p*/, n ) {
+
+			// not sure what to do here, the data isn't really useful.
+			return stream.Seek( sizeof( T ) * n, aiOrigin_CUR );
+
+		}
+
+		function ai_assert( bool ) {
+
+			if ( ! bool )
+				throw ( "asset failed" );
+
+		}
+
+		function ReadBinaryNode( stream, parent, depth ) {
+
+			var chunkID = Read_uint32_t( stream );
+			ai_assert( chunkID == ASSBIN_CHUNK_AINODE );
+			/*uint32_t size =*/
+			Read_uint32_t( stream );
+			var node = new aiNode();
+			node.mParent = parent;
+			node.mDepth = depth;
+			node.mName = Read_aiString( stream );
+			node.mTransformation = Read_aiMatrix4x4( stream );
+			node.mNumChildren = Read_unsigned_int( stream );
+			node.mNumMeshes = Read_unsigned_int( stream );
+
+			if ( node.mNumMeshes ) {
+
+				node.mMeshes = [];
+
+				for ( var i = 0; i < node.mNumMeshes; ++ i ) {
+
+					node.mMeshes[ i ] = Read_unsigned_int( stream );
+
+				}
+
+			}
+
+			if ( node.mNumChildren ) {
+
+				node.mChildren = [];
+
+				for ( var i = 0; i < node.mNumChildren; ++ i ) {
+
+					var node2 = ReadBinaryNode( stream, node, depth ++ );
+					node.mChildren[ i ] = node2;
+
+				}
+
+			}
+
+			return node;
+
+		}
+
+		// -----------------------------------------------------------------------------------
+
+		function ReadBinaryBone( stream, b ) {
+
+			var chunkID = Read_uint32_t( stream );
+			ai_assert( chunkID == ASSBIN_CHUNK_AIBONE );
+			/*uint32_t size =*/
+			Read_uint32_t( stream );
+			b.mName = Read_aiString( stream );
+			b.mNumWeights = Read_unsigned_int( stream );
+			b.mOffsetMatrix = Read_aiMatrix4x4( stream );
+			// for the moment we write dumb min/max values for the bones, too.
+			// maybe I'll add a better, hash-like solution later
+			if ( shortened ) {
+
+				ReadBounds( stream, b.mWeights, b.mNumWeights );
+
+			} else {
+
+				// else write as usual
+
+				b.mWeights = [];
+				ReadArray_aiVertexWeight( stream, b.mWeights, b.mNumWeights );
+
+			}
+
+			return b;
+
+		}
+
+		function ReadBinaryMesh( stream, mesh ) {
+
+			var chunkID = Read_uint32_t( stream );
+			ai_assert( chunkID == ASSBIN_CHUNK_AIMESH );
+			/*uint32_t size =*/
+			Read_uint32_t( stream );
+			mesh.mPrimitiveTypes = Read_unsigned_int( stream );
+			mesh.mNumVertices = Read_unsigned_int( stream );
+			mesh.mNumFaces = Read_unsigned_int( stream );
+			mesh.mNumBones = Read_unsigned_int( stream );
+			mesh.mMaterialIndex = Read_unsigned_int( stream );
+			mesh.mNumUVComponents = [];
+			// first of all, write bits for all existent vertex components
+			var c = Read_unsigned_int( stream );
+
+			if ( c & ASSBIN_MESH_HAS_POSITIONS ) {
+
+				if ( shortened ) {
+
+					ReadBounds( stream, mesh.mVertices, mesh.mNumVertices );
+
+				} else {
+
+					// else write as usual
+
+					mesh.mVertices = [];
+					mesh.mVertexBuffer = stream.subArray32( stream.readOffset, stream.readOffset + mesh.mNumVertices * 3 * 4 );
+					stream.Seek( mesh.mNumVertices * 3 * 4, aiOrigin_CUR );
+
+				}
+
+			}
+
+			if ( c & ASSBIN_MESH_HAS_NORMALS ) {
+
+				if ( shortened ) {
+
+					ReadBounds( stream, mesh.mNormals, mesh.mNumVertices );
+
+				} else {
+
+					// else write as usual
+
+					mesh.mNormals = [];
+					mesh.mNormalBuffer = stream.subArray32( stream.readOffset, stream.readOffset + mesh.mNumVertices * 3 * 4 );
+					stream.Seek( mesh.mNumVertices * 3 * 4, aiOrigin_CUR );
+
+				}
+
+			}
+
+			if ( c & ASSBIN_MESH_HAS_TANGENTS_AND_BITANGENTS ) {
+
+				if ( shortened ) {
+
+					ReadBounds( stream, mesh.mTangents, mesh.mNumVertices );
+					ReadBounds( stream, mesh.mBitangents, mesh.mNumVertices );
+
+				} else {
+
+					// else write as usual
+
+					mesh.mTangents = [];
+					mesh.mTangentBuffer = stream.subArray32( stream.readOffset, stream.readOffset + mesh.mNumVertices * 3 * 4 );
+					stream.Seek( mesh.mNumVertices * 3 * 4, aiOrigin_CUR );
+					mesh.mBitangents = [];
+					mesh.mBitangentBuffer = stream.subArray32( stream.readOffset, stream.readOffset + mesh.mNumVertices * 3 * 4 );
+					stream.Seek( mesh.mNumVertices * 3 * 4, aiOrigin_CUR );
+
+				}
+
+			}
+
+			for ( var n = 0; n < AI_MAX_NUMBER_OF_COLOR_SETS; ++ n ) {
+
+				if ( ! ( c & ASSBIN_MESH_HAS_COLOR( n ) ) ) break;
+
+				if ( shortened ) {
+
+					ReadBounds( stream, mesh.mColors[ n ], mesh.mNumVertices );
+
+				} else {
+
+					// else write as usual
+
+					mesh.mColors[ n ] = [];
+					mesh.mColorBuffer = stream.subArray32( stream.readOffset, stream.readOffset + mesh.mNumVertices * 4 * 4 );
+					stream.Seek( mesh.mNumVertices * 4 * 4, aiOrigin_CUR );
+
+				}
+
+			}
+
+			mesh.mTexCoordsBuffers = [];
+
+			for ( var n = 0; n < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++ n ) {
+
+				if ( ! ( c & ASSBIN_MESH_HAS_TEXCOORD( n ) ) ) break;
+
+				// write number of UV components
+				mesh.mNumUVComponents[ n ] = Read_unsigned_int( stream );
+
+				if ( shortened ) {
+
+					ReadBounds( stream, mesh.mTextureCoords[ n ], mesh.mNumVertices );
+
+				} else {
+
+					// else write as usual
+
+					mesh.mTextureCoords[ n ] = [];
+					//note that assbin always writes 3d texcoords
+					mesh.mTexCoordsBuffers[ n ] = [];
+
+					for ( var uv = 0; uv < mesh.mNumVertices; uv ++ ) {
+
+						mesh.mTexCoordsBuffers[ n ].push( readFloat( stream ) );
+						mesh.mTexCoordsBuffers[ n ].push( readFloat( stream ) );
+						readFloat( stream );
+
+					}
+
+				}
+
+			}
+			// write faces. There are no floating-point calculations involved
+			// in these, so we can write a simple hash over the face data
+			// to the dump file. We generate a single 32 Bit hash for 512 faces
+			// using Assimp's standard hashing function.
+			if ( shortened ) {
+
+				Read_unsigned_int( stream );
+
+			} else {
+
+				// else write as usual
+
+				// if there are less than 2^16 vertices, we can simply use 16 bit integers ...
+				mesh.mFaces = [];
+
+				var indexCounter = 0;
+				mesh.mIndexArray = [];
+
+				for ( var i = 0; i < mesh.mNumFaces; ++ i ) {
+
+					var f = mesh.mFaces[ i ] = new aiFace();
+					// BOOST_STATIC_ASSERT(AI_MAX_FACE_INDICES <= 0xffff);
+					f.mNumIndices = Read_uint16_t( stream );
+					f.mIndices = [];
+
+					for ( var a = 0; a < f.mNumIndices; ++ a ) {
+
+						if ( mesh.mNumVertices < ( 1 << 16 ) ) {
+
+							f.mIndices[ a ] = Read_uint16_t( stream );
+
+						} else {
+
+							f.mIndices[ a ] = Read_unsigned_int( stream );
+
+						}
+
+
+
+					}
+
+					if ( f.mNumIndices === 3 ) {
+
+						mesh.mIndexArray.push( f.mIndices[ 0 ] );
+						mesh.mIndexArray.push( f.mIndices[ 1 ] );
+						mesh.mIndexArray.push( f.mIndices[ 2 ] );
+
+					} else if ( f.mNumIndices === 4 ) {
+
+						mesh.mIndexArray.push( f.mIndices[ 0 ] );
+						mesh.mIndexArray.push( f.mIndices[ 1 ] );
+						mesh.mIndexArray.push( f.mIndices[ 2 ] );
+						mesh.mIndexArray.push( f.mIndices[ 2 ] );
+						mesh.mIndexArray.push( f.mIndices[ 3 ] );
+						mesh.mIndexArray.push( f.mIndices[ 0 ] );
+
+					} else {
+
+						throw ( new Error( "Sorry, can't currently triangulate polys. Use the triangulate preprocessor in Assimp." ) );
+
+					}
+
+
+
+				}
+
+			}
+			// write bones
+			if ( mesh.mNumBones ) {
+
+				mesh.mBones = [];
+
+				for ( var a = 0; a < mesh.mNumBones; ++ a ) {
+
+					mesh.mBones[ a ] = new aiBone();
+					ReadBinaryBone( stream, mesh.mBones[ a ] );
+
+				}
+
+			}
+
+		}
+
+		function ReadBinaryMaterialProperty( stream, prop ) {
+
+			var chunkID = Read_uint32_t( stream );
+			ai_assert( chunkID == ASSBIN_CHUNK_AIMATERIALPROPERTY );
+			/*uint32_t size =*/
+			Read_uint32_t( stream );
+			prop.mKey = Read_aiString( stream );
+			prop.mSemantic = Read_unsigned_int( stream );
+			prop.mIndex = Read_unsigned_int( stream );
+			prop.mDataLength = Read_unsigned_int( stream );
+			prop.mType = Read_unsigned_int( stream );
+			prop.mData = [];
+			stream.ReadBytes( prop.mData, 1, prop.mDataLength );
+
+		}
+
+		// -----------------------------------------------------------------------------------
+
+		function ReadBinaryMaterial( stream, mat ) {
+
+			var chunkID = Read_uint32_t( stream );
+			ai_assert( chunkID == ASSBIN_CHUNK_AIMATERIAL );
+			/*uint32_t size =*/
+			Read_uint32_t( stream );
+			mat.mNumAllocated = mat.mNumProperties = Read_unsigned_int( stream );
+
+			if ( mat.mNumProperties ) {
+
+				if ( mat.mProperties ) {
+
+					delete mat.mProperties;
+
+				}
+
+				mat.mProperties = [];
+
+				for ( var i = 0; i < mat.mNumProperties; ++ i ) {
+
+					mat.mProperties[ i ] = new aiMaterialProperty();
+					ReadBinaryMaterialProperty( stream, mat.mProperties[ i ] );
+
+				}
+
+			}
+
+		}
+		// -----------------------------------------------------------------------------------
+		function ReadBinaryNodeAnim( stream, nd ) {
+
+			var chunkID = Read_uint32_t( stream );
+			ai_assert( chunkID == ASSBIN_CHUNK_AINODEANIM );
+			/*uint32_t size =*/
+			Read_uint32_t( stream );
+			nd.mNodeName = Read_aiString( stream );
+			nd.mNumPositionKeys = Read_unsigned_int( stream );
+			nd.mNumRotationKeys = Read_unsigned_int( stream );
+			nd.mNumScalingKeys = Read_unsigned_int( stream );
+			nd.mPreState = Read_unsigned_int( stream );
+			nd.mPostState = Read_unsigned_int( stream );
+
+			if ( nd.mNumPositionKeys ) {
+
+				if ( shortened ) {
+
+					ReadBounds( stream, nd.mPositionKeys, nd.mNumPositionKeys );
+
+				} else {
+
+					// else write as usual
+
+					nd.mPositionKeys = [];
+					ReadArray_aiVectorKey( stream, nd.mPositionKeys, nd.mNumPositionKeys );
+
+				}
+
+			}
+
+			if ( nd.mNumRotationKeys ) {
+
+				if ( shortened ) {
+
+					ReadBounds( stream, nd.mRotationKeys, nd.mNumRotationKeys );
+
+				} else {
+
+		 			// else write as usual
+
+					nd.mRotationKeys = [];
+					ReadArray_aiQuatKey( stream, nd.mRotationKeys, nd.mNumRotationKeys );
+
+				}
+
+			}
+
+			if ( nd.mNumScalingKeys ) {
+
+				if ( shortened ) {
+
+					ReadBounds( stream, nd.mScalingKeys, nd.mNumScalingKeys );
+
+				} else {
+
+	 				// else write as usual
+
+					nd.mScalingKeys = [];
+					ReadArray_aiVectorKey( stream, nd.mScalingKeys, nd.mNumScalingKeys );
+
+				}
+
+			}
+
+		}
+		// -----------------------------------------------------------------------------------
+		function ReadBinaryAnim( stream, anim ) {
+
+			var chunkID = Read_uint32_t( stream );
+			ai_assert( chunkID == ASSBIN_CHUNK_AIANIMATION );
+			/*uint32_t size =*/
+			Read_uint32_t( stream );
+			anim.mName = Read_aiString( stream );
+			anim.mDuration = Read_double( stream );
+			anim.mTicksPerSecond = Read_double( stream );
+			anim.mNumChannels = Read_unsigned_int( stream );
+
+			if ( anim.mNumChannels ) {
+
+				anim.mChannels = [];
+
+				for ( var a = 0; a < anim.mNumChannels; ++ a ) {
+
+					anim.mChannels[ a ] = new aiNodeAnim();
+					ReadBinaryNodeAnim( stream, anim.mChannels[ a ] );
+
+				}
+
+			}
+
+		}
+
+		function ReadBinaryTexture( stream, tex ) {
+
+			var chunkID = Read_uint32_t( stream );
+			ai_assert( chunkID == ASSBIN_CHUNK_AITEXTURE );
+			/*uint32_t size =*/
+			Read_uint32_t( stream );
+			tex.mWidth = Read_unsigned_int( stream );
+			tex.mHeight = Read_unsigned_int( stream );
+			stream.ReadBytes( tex.achFormatHint, 1, 4 );
+
+			if ( ! shortened ) {
+
+				if ( ! tex.mHeight ) {
+
+					tex.pcData = [];
+					stream.ReadBytes( tex.pcData, 1, tex.mWidth );
+
+				} else {
+
+					tex.pcData = [];
+					stream.ReadBytes( tex.pcData, 1, tex.mWidth * tex.mHeight * 4 );
+
+				}
+
+			}
+
+		}
+		// -----------------------------------------------------------------------------------
+		function ReadBinaryLight( stream, l ) {
+
+			var chunkID = Read_uint32_t( stream );
+			ai_assert( chunkID == ASSBIN_CHUNK_AILIGHT );
+			/*uint32_t size =*/
+			Read_uint32_t( stream );
+			l.mName = Read_aiString( stream );
+			l.mType = Read_unsigned_int( stream );
+
+			if ( l.mType != aiLightSource_DIRECTIONAL ) {
+
+				l.mAttenuationConstant = readFloat( stream );
+				l.mAttenuationLinear = readFloat( stream );
+				l.mAttenuationQuadratic = readFloat( stream );
+
+			}
+
+			l.mColorDiffuse = Read_aiColor3D( stream );
+			l.mColorSpecular = Read_aiColor3D( stream );
+			l.mColorAmbient = Read_aiColor3D( stream );
+
+			if ( l.mType == aiLightSource_SPOT ) {
+
+				l.mAngleInnerCone = readFloat( stream );
+				l.mAngleOuterCone = readFloat( stream );
+
+			}
+
+		}
+		// -----------------------------------------------------------------------------------
+		function ReadBinaryCamera( stream, cam ) {
+
+			var chunkID = Read_uint32_t( stream );
+			ai_assert( chunkID == ASSBIN_CHUNK_AICAMERA );
+			/*uint32_t size =*/
+			Read_uint32_t( stream );
+			cam.mName = Read_aiString( stream );
+			cam.mPosition = Read_aiVector3D( stream );
+			cam.mLookAt = Read_aiVector3D( stream );
+			cam.mUp = Read_aiVector3D( stream );
+			cam.mHorizontalFOV = readFloat( stream );
+			cam.mClipPlaneNear = readFloat( stream );
+			cam.mClipPlaneFar = readFloat( stream );
+			cam.mAspect = readFloat( stream );
+
+		}
+
+		function ReadBinaryScene( stream, scene ) {
+
+			var chunkID = Read_uint32_t( stream );
+			ai_assert( chunkID == ASSBIN_CHUNK_AISCENE );
+			/*uint32_t size =*/
+			Read_uint32_t( stream );
+			scene.mFlags = Read_unsigned_int( stream );
+			scene.mNumMeshes = Read_unsigned_int( stream );
+			scene.mNumMaterials = Read_unsigned_int( stream );
+			scene.mNumAnimations = Read_unsigned_int( stream );
+			scene.mNumTextures = Read_unsigned_int( stream );
+			scene.mNumLights = Read_unsigned_int( stream );
+			scene.mNumCameras = Read_unsigned_int( stream );
+			// Read node graph
+			scene.mRootNode = new aiNode();
+			scene.mRootNode = ReadBinaryNode( stream, null, 0 );
+			// Read all meshes
+			if ( scene.mNumMeshes ) {
+
+				scene.mMeshes = [];
+
+				for ( var i = 0; i < scene.mNumMeshes; ++ i ) {
+
+					scene.mMeshes[ i ] = new aiMesh();
+					ReadBinaryMesh( stream, scene.mMeshes[ i ] );
+
+				}
+
+			}
+			// Read materials
+			if ( scene.mNumMaterials ) {
+
+				scene.mMaterials = [];
+
+				for ( var i = 0; i < scene.mNumMaterials; ++ i ) {
+
+					scene.mMaterials[ i ] = new aiMaterial();
+					ReadBinaryMaterial( stream, scene.mMaterials[ i ] );
+
+				}
+
+			}
+			// Read all animations
+			if ( scene.mNumAnimations ) {
+
+				scene.mAnimations = [];
+
+				for ( var i = 0; i < scene.mNumAnimations; ++ i ) {
+
+					scene.mAnimations[ i ] = new aiAnimation();
+					ReadBinaryAnim( stream, scene.mAnimations[ i ] );
+
+				}
+
+			}
+			// Read all textures
+			if ( scene.mNumTextures ) {
+
+				scene.mTextures = [];
+
+				for ( var i = 0; i < scene.mNumTextures; ++ i ) {
+
+					scene.mTextures[ i ] = new aiTexture();
+					ReadBinaryTexture( stream, scene.mTextures[ i ] );
+
+				}
+
+			}
+			// Read lights
+			if ( scene.mNumLights ) {
+
+				scene.mLights = [];
+
+				for ( var i = 0; i < scene.mNumLights; ++ i ) {
+
+					scene.mLights[ i ] = new aiLight();
+					ReadBinaryLight( stream, scene.mLights[ i ] );
+
+				}
+
+			}
+			// Read cameras
+			if ( scene.mNumCameras ) {
+
+				scene.mCameras = [];
+
+				for ( var i = 0; i < scene.mNumCameras; ++ i ) {
+
+					scene.mCameras[ i ] = new aiCamera();
+					ReadBinaryCamera( stream, scene.mCameras[ i ] );
+
+				}
+
+			}
+
+		}
+		var aiOrigin_CUR = 0;
+		var aiOrigin_BEG = 1;
+
+		function extendStream( stream ) {
+
+			stream.readOffset = 0;
+			stream.Seek = function ( off, ori ) {
+
+				if ( ori == aiOrigin_CUR ) {
+
+					stream.readOffset += off;
+
+				}
+				if ( ori == aiOrigin_BEG ) {
+
+					stream.readOffset = off;
+
+				}
+
+			};
+
+			stream.ReadBytes = function ( buff, size, n ) {
+
+				var bytes = size * n;
+				for ( var i = 0; i < bytes; i ++ )
+					buff[ i ] = Read_uint8_t( this );
+
+			};
+
+			stream.subArray32 = function ( start, end ) {
+
+				var buff = this.buffer;
+				var newbuff = buff.slice( start, end );
+				return new Float32Array( newbuff );
+
+			};
+
+			stream.subArrayUint16 = function ( start, end ) {
+
+				var buff = this.buffer;
+				var newbuff = buff.slice( start, end );
+				return new Uint16Array( newbuff );
+
+			};
+
+			stream.subArrayUint8 = function ( start, end ) {
+
+				var buff = this.buffer;
+				var newbuff = buff.slice( start, end );
+				return new Uint8Array( newbuff );
+
+			};
+
+			stream.subArrayUint32 = function ( start, end ) {
+
+				var buff = this.buffer;
+				var newbuff = buff.slice( start, end );
+				return new Uint32Array( newbuff );
+
+			};
+
+		}
+
+		var shortened, compressed;
+
+		function InternReadFile( pFiledata ) {
+
+			var pScene = new aiScene();
+			var stream = new DataView( pFiledata );
+			extendStream( stream );
+			stream.Seek( 44, aiOrigin_CUR ); // signature
+			/*unsigned int versionMajor =*/
+			var versionMajor = Read_unsigned_int( stream );
+			/*unsigned int versionMinor =*/
+			var versionMinor = Read_unsigned_int( stream );
+			/*unsigned int versionRevision =*/
+			var versionRevision = Read_unsigned_int( stream );
+			/*unsigned int compileFlags =*/
+			var compileFlags = Read_unsigned_int( stream );
+			shortened = Read_uint16_t( stream ) > 0;
+			compressed = Read_uint16_t( stream ) > 0;
+			if ( shortened )
+				throw "Shortened binaries are not supported!";
+			stream.Seek( 256, aiOrigin_CUR ); // original filename
+			stream.Seek( 128, aiOrigin_CUR ); // options
+			stream.Seek( 64, aiOrigin_CUR ); // padding
+			if ( compressed ) {
+
+				var uncompressedSize = Read_uint32_t( stream );
+				var compressedSize = stream.FileSize() - stream.Tell();
+				var compressedData = [];
+				stream.Read( compressedData, 1, compressedSize );
+				var uncompressedData = [];
+				uncompress( uncompressedData, uncompressedSize, compressedData, compressedSize );
+				var buff = new ArrayBuffer( uncompressedData );
+				ReadBinaryScene( buff, pScene );
+
+			} else {
+
+				ReadBinaryScene( stream, pScene );
+				return pScene.toTHREE();
+
+			}
+
+		}
+
+		return InternReadFile( buffer );
+
+	}
+
+};
+
+export { AssimpLoader };

+ 1 - 0
examples/jsm/loaders/DDSLoader.d.ts

@@ -18,4 +18,5 @@ export class DDSLoader extends CompressedTextureLoader {
   constructor(manager?: LoadingManager);
 
   parse(buffer: ArrayBuffer, loadMipmaps: boolean) : DDS;
+  _parser(buffer: ArrayBuffer, loadMipmaps: boolean) : DDS;
 }

+ 1 - 1
examples/jsm/loaders/EXRLoader.d.ts

@@ -17,5 +17,5 @@ export interface EXR {
 export class EXRLoader extends DataTextureLoader {
   constructor(manager?: LoadingManager);
 
-  parse(buffer: ArrayBuffer) : EXR;
+  _parser(buffer: ArrayBuffer) : EXR;
 }

+ 16 - 0
examples/jsm/loaders/GCodeLoader.d.ts

@@ -0,0 +1,16 @@
+import {
+  Group
+  LoadingManager
+} from '../../../src/Three';
+
+export class GCodeLoader {
+  constructor(manager?: LoadingManager);
+  manager: LoadingManager;
+  path: string;
+  splitLayer: boolean;
+
+  load(url: string, onLoad: (object: Group) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void) : void;
+  setPath(path: string) : this;
+
+  parse(data: string) : Group;
+}

+ 243 - 0
examples/jsm/loaders/GCodeLoader.js

@@ -0,0 +1,243 @@
+/**
+ * GCodeLoader is used to load gcode files usually used for 3D printing or CNC applications.
+ *
+ * Gcode files are composed by commands used by machines to create objects.
+ *
+ * @class GCodeLoader
+ * @param {Manager} manager Loading manager.
+ * @author tentone
+ * @author joewalnes
+ */
+
+import {
+	BufferGeometry,
+	DefaultLoadingManager,
+	Euler,
+	FileLoader,
+	Float32BufferAttribute,
+	Group,
+	LineBasicMaterial,
+	LineSegments
+} from "../../../build/three.module.js";
+
+var GCodeLoader = function ( manager ) {
+
+	this.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager;
+
+	this.splitLayer = false;
+
+};
+
+GCodeLoader.prototype = {
+
+	constructor: GCodeLoader,
+
+	load: function ( url, onLoad, onProgress, onError ) {
+
+		var self = this;
+
+		var loader = new FileLoader( self.manager );
+		loader.setPath( self.path );
+		loader.load( url, function ( text ) {
+
+			onLoad( self.parse( text ) );
+
+		}, onProgress, onError );
+
+	},
+
+	setPath: function ( value ) {
+
+		this.path = value;
+		return this;
+
+	},
+
+	parse: function ( data ) {
+
+		var state = { x: 0, y: 0, z: 0, e: 0, f: 0, extruding: false, relative: false };
+		var layers = [];
+
+		var currentLayer = undefined;
+
+		var pathMaterial = new LineBasicMaterial( { color: 0xFF0000 } );
+		pathMaterial.name = 'path';
+
+		var extrudingMaterial = new LineBasicMaterial( { color: 0x00FF00 } );
+		extrudingMaterial.name = 'extruded';
+
+		function newLayer( line ) {
+
+			currentLayer = { vertex: [], pathVertex: [], z: line.z };
+			layers.push( currentLayer );
+
+		}
+
+		//Create lie segment between p1 and p2
+		function addSegment( p1, p2 ) {
+
+			if ( currentLayer === undefined ) {
+
+				newLayer( p1 );
+
+			}
+
+			if ( line.extruding ) {
+
+				currentLayer.vertex.push( p1.x, p1.y, p1.z );
+				currentLayer.vertex.push( p2.x, p2.y, p2.z );
+
+			} else {
+
+				currentLayer.pathVertex.push( p1.x, p1.y, p1.z );
+				currentLayer.pathVertex.push( p2.x, p2.y, p2.z );
+
+			}
+
+		}
+
+		function delta( v1, v2 ) {
+
+			return state.relative ? v2 : v2 - v1;
+
+		}
+
+		function absolute( v1, v2 ) {
+
+			return state.relative ? v1 + v2 : v2;
+
+		}
+
+		var lines = data.replace( /;.+/g, '' ).split( '\n' );
+
+		for ( var i = 0; i < lines.length; i ++ ) {
+
+			var tokens = lines[ i ].split( ' ' );
+			var cmd = tokens[ 0 ].toUpperCase();
+
+			//Argumments
+			var args = {};
+			tokens.splice( 1 ).forEach( function ( token ) {
+
+				if ( token[ 0 ] !== undefined ) {
+
+					var key = token[ 0 ].toLowerCase();
+					var value = parseFloat( token.substring( 1 ) );
+					args[ key ] = value;
+
+				}
+
+			} );
+
+			//Process commands
+			//G0/G1 – Linear Movement
+			if ( cmd === 'G0' || cmd === 'G1' ) {
+
+				var line = {
+					x: args.x !== undefined ? absolute( state.x, args.x ) : state.x,
+					y: args.y !== undefined ? absolute( state.y, args.y ) : state.y,
+					z: args.z !== undefined ? absolute( state.z, args.z ) : state.z,
+					e: args.e !== undefined ? absolute( state.e, args.e ) : state.e,
+					f: args.f !== undefined ? absolute( state.f, args.f ) : state.f,
+				};
+
+				//Layer change detection is or made by watching Z, it's made by watching when we extrude at a new Z position
+				if ( delta( state.e, line.e ) > 0 ) {
+
+					line.extruding = delta( state.e, line.e ) > 0;
+
+					if ( currentLayer == undefined || line.z != currentLayer.z ) {
+
+						newLayer( line );
+
+					}
+
+				}
+
+				addSegment( state, line );
+				state = line;
+
+			} else if ( cmd === 'G2' || cmd === 'G3' ) {
+
+				//G2/G3 - Arc Movement ( G2 clock wise and G3 counter clock wise )
+				//console.warn( 'THREE.GCodeLoader: Arc command not supported' );
+
+			} else if ( cmd === 'G90' ) {
+
+				//G90: Set to Absolute Positioning
+				state.relative = false;
+
+			} else if ( cmd === 'G91' ) {
+
+				//G91: Set to state.relative Positioning
+				state.relative = true;
+
+			} else if ( cmd === 'G92' ) {
+
+				//G92: Set Position
+				var line = state;
+				line.x = args.x !== undefined ? args.x : line.x;
+				line.y = args.y !== undefined ? args.y : line.y;
+				line.z = args.z !== undefined ? args.z : line.z;
+				line.e = args.e !== undefined ? args.e : line.e;
+				state = line;
+
+			} else {
+
+				//console.warn( 'THREE.GCodeLoader: Command not supported:' + cmd );
+
+			}
+
+		}
+
+		function addObject( vertex, extruding ) {
+
+			var geometry = new BufferGeometry();
+			geometry.addAttribute( 'position', new Float32BufferAttribute( vertex, 3 ) );
+
+			var segments = new LineSegments( geometry, extruding ? extrudingMaterial : pathMaterial );
+			segments.name = 'layer' + i;
+			object.add( segments );
+
+		}
+
+		var object = new Group();
+		object.name = 'gcode';
+
+		if ( this.splitLayer ) {
+
+			for ( var i = 0; i < layers.length; i ++ ) {
+
+				var layer = layers[ i ];
+				addObject( layer.vertex, true );
+				addObject( layer.pathVertex, false );
+
+			}
+
+		} else {
+
+			var vertex = [], pathVertex = [];
+
+			for ( var i = 0; i < layers.length; i ++ ) {
+
+				var layer = layers[ i ];
+
+				vertex = vertex.concat( layer.vertex );
+				pathVertex = pathVertex.concat( layer.pathVertex );
+
+			}
+
+			addObject( vertex, true );
+			addObject( pathVertex, false );
+
+		}
+
+		object.quaternion.setFromEuler( new Euler( - Math.PI / 2, 0, 0 ) );
+
+		return object;
+
+	}
+
+};
+
+export { GCodeLoader };

+ 25 - 0
examples/jsm/loaders/RGBELoader.d.ts

@@ -0,0 +1,25 @@
+import {
+  LoadingManager,
+  DataTextureLoader,
+  TextureDataType,
+  PixelFormat
+} from '../../../src/Three';
+
+export interface RGBE {
+  width: number;
+  height: number;
+  data: Float32Array | Uint8Array;
+  header: string;
+  gamma: number;
+  exposure: number;
+  format: PixelFormat;
+  type: TextureDataType;
+}
+
+export class RGBELoader extends DataTextureLoader {
+  constructor(manager?: LoadingManager);
+  type: TextureDataType;
+
+  _parser(buffer: ArrayBuffer): RGBE;
+  setType(type: TextureDataType): this;
+}

+ 404 - 0
examples/jsm/loaders/RGBELoader.js

@@ -0,0 +1,404 @@
+/**
+ * @author Nikos M. / https://github.com/foo123/
+ */
+
+import {
+	DataTextureLoader,
+	DefaultLoadingManager,
+	FloatType,
+	RGBEFormat,
+	RGBFormat,
+	UnsignedByteType
+} from "../../../build/three.module.js";
+
+// https://github.com/mrdoob/three.js/issues/5552
+// http://en.wikipedia.org/wiki/RGBE_image_format
+
+var RGBELoader = function ( manager ) {
+
+	this.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager;
+	this.type = UnsignedByteType;
+
+};
+
+// extend DataTextureLoader
+RGBELoader.prototype = Object.create( DataTextureLoader.prototype );
+
+// adapted from http://www.graphics.cornell.edu/~bjw/rgbe.html
+RGBELoader.prototype._parser = function ( buffer ) {
+
+	var
+		/* return codes for rgbe routines */
+		RGBE_RETURN_SUCCESS = 0,
+		RGBE_RETURN_FAILURE = - 1,
+
+		/* default error routine.  change this to change error handling */
+		rgbe_read_error = 1,
+		rgbe_write_error = 2,
+		rgbe_format_error = 3,
+		rgbe_memory_error = 4,
+		rgbe_error = function ( rgbe_error_code, msg ) {
+
+			switch ( rgbe_error_code ) {
+
+				case rgbe_read_error: console.error( "RGBELoader Read Error: " + ( msg || '' ) );
+					break;
+				case rgbe_write_error: console.error( "RGBELoader Write Error: " + ( msg || '' ) );
+					break;
+				case rgbe_format_error: console.error( "RGBELoader Bad File Format: " + ( msg || '' ) );
+					break;
+				default:
+				case rgbe_memory_error: console.error( "RGBELoader: Error: " + ( msg || '' ) );
+
+			}
+			return RGBE_RETURN_FAILURE;
+
+		},
+
+		/* offsets to red, green, and blue components in a data (float) pixel */
+		RGBE_DATA_RED = 0,
+		RGBE_DATA_GREEN = 1,
+		RGBE_DATA_BLUE = 2,
+
+		/* number of floats per pixel, use 4 since stored in rgba image format */
+		RGBE_DATA_SIZE = 4,
+
+		/* flags indicating which fields in an rgbe_header_info are valid */
+		RGBE_VALID_PROGRAMTYPE = 1,
+		RGBE_VALID_FORMAT = 2,
+		RGBE_VALID_DIMENSIONS = 4,
+
+		NEWLINE = "\n",
+
+		fgets = function ( buffer, lineLimit, consume ) {
+
+			lineLimit = ! lineLimit ? 1024 : lineLimit;
+			var p = buffer.pos,
+				i = - 1, len = 0, s = '', chunkSize = 128,
+				chunk = String.fromCharCode.apply( null, new Uint16Array( buffer.subarray( p, p + chunkSize ) ) )
+			;
+			while ( ( 0 > ( i = chunk.indexOf( NEWLINE ) ) ) && ( len < lineLimit ) && ( p < buffer.byteLength ) ) {
+
+				s += chunk; len += chunk.length;
+				p += chunkSize;
+				chunk += String.fromCharCode.apply( null, new Uint16Array( buffer.subarray( p, p + chunkSize ) ) );
+
+			}
+
+			if ( - 1 < i ) {
+
+				/*for (i=l-1; i>=0; i--) {
+					byteCode = m.charCodeAt(i);
+					if (byteCode > 0x7f && byteCode <= 0x7ff) byteLen++;
+					else if (byteCode > 0x7ff && byteCode <= 0xffff) byteLen += 2;
+					if (byteCode >= 0xDC00 && byteCode <= 0xDFFF) i--; //trail surrogate
+				}*/
+				if ( false !== consume ) buffer.pos += len + i + 1;
+				return s + chunk.slice( 0, i );
+
+			}
+			return false;
+
+		},
+
+		/* minimal header reading.  modify if you want to parse more information */
+		RGBE_ReadHeader = function ( buffer ) {
+
+			var line, match,
+
+				// regexes to parse header info fields
+				magic_token_re = /^#\?(\S+)$/,
+				gamma_re = /^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,
+				exposure_re = /^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,
+				format_re = /^\s*FORMAT=(\S+)\s*$/,
+				dimensions_re = /^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,
+
+				// RGBE format header struct
+				header = {
+
+					valid: 0, /* indicate which fields are valid */
+
+					string: '', /* the actual header string */
+
+					comments: '', /* comments found in header */
+
+					programtype: 'RGBE', /* listed at beginning of file to identify it after "#?". defaults to "RGBE" */
+
+					format: '', /* RGBE format, default 32-bit_rle_rgbe */
+
+					gamma: 1.0, /* image has already been gamma corrected with given gamma. defaults to 1.0 (no correction) */
+
+					exposure: 1.0, /* a value of 1.0 in an image corresponds to <exposure> watts/steradian/m^2. defaults to 1.0 */
+
+					width: 0, height: 0 /* image dimensions, width/height */
+
+				};
+
+			if ( buffer.pos >= buffer.byteLength || ! ( line = fgets( buffer ) ) ) {
+
+				return rgbe_error( rgbe_read_error, "no header found" );
+
+			}
+			/* if you want to require the magic token then uncomment the next line */
+			if ( ! ( match = line.match( magic_token_re ) ) ) {
+
+				return rgbe_error( rgbe_format_error, "bad initial token" );
+
+			}
+			header.valid |= RGBE_VALID_PROGRAMTYPE;
+			header.programtype = match[ 1 ];
+			header.string += line + "\n";
+
+			while ( true ) {
+
+				line = fgets( buffer );
+				if ( false === line ) break;
+				header.string += line + "\n";
+
+				if ( '#' === line.charAt( 0 ) ) {
+
+					header.comments += line + "\n";
+					continue; // comment line
+
+				}
+
+				if ( match = line.match( gamma_re ) ) {
+
+					header.gamma = parseFloat( match[ 1 ], 10 );
+
+				}
+				if ( match = line.match( exposure_re ) ) {
+
+					header.exposure = parseFloat( match[ 1 ], 10 );
+
+				}
+				if ( match = line.match( format_re ) ) {
+
+					header.valid |= RGBE_VALID_FORMAT;
+					header.format = match[ 1 ];//'32-bit_rle_rgbe';
+
+				}
+				if ( match = line.match( dimensions_re ) ) {
+
+					header.valid |= RGBE_VALID_DIMENSIONS;
+					header.height = parseInt( match[ 1 ], 10 );
+					header.width = parseInt( match[ 2 ], 10 );
+
+				}
+
+				if ( ( header.valid & RGBE_VALID_FORMAT ) && ( header.valid & RGBE_VALID_DIMENSIONS ) ) break;
+
+			}
+
+			if ( ! ( header.valid & RGBE_VALID_FORMAT ) ) {
+
+				return rgbe_error( rgbe_format_error, "missing format specifier" );
+
+			}
+			if ( ! ( header.valid & RGBE_VALID_DIMENSIONS ) ) {
+
+				return rgbe_error( rgbe_format_error, "missing image size specifier" );
+
+			}
+
+			return header;
+
+		},
+
+		RGBE_ReadPixels_RLE = function ( buffer, w, h ) {
+
+			var data_rgba, offset, pos, count, byteValue,
+				scanline_buffer, ptr, ptr_end, i, l, off, isEncodedRun,
+				scanline_width = w, num_scanlines = h, rgbeStart
+			;
+
+			if (
+				// run length encoding is not allowed so read flat
+				( ( scanline_width < 8 ) || ( scanline_width > 0x7fff ) ) ||
+				// this file is not run length encoded
+				( ( 2 !== buffer[ 0 ] ) || ( 2 !== buffer[ 1 ] ) || ( buffer[ 2 ] & 0x80 ) )
+			) {
+
+				// return the flat buffer
+				return new Uint8Array( buffer );
+
+			}
+
+			if ( scanline_width !== ( ( buffer[ 2 ] << 8 ) | buffer[ 3 ] ) ) {
+
+				return rgbe_error( rgbe_format_error, "wrong scanline width" );
+
+			}
+
+			data_rgba = new Uint8Array( 4 * w * h );
+
+			if ( ! data_rgba || ! data_rgba.length ) {
+
+				return rgbe_error( rgbe_memory_error, "unable to allocate buffer space" );
+
+			}
+
+			offset = 0; pos = 0; ptr_end = 4 * scanline_width;
+			rgbeStart = new Uint8Array( 4 );
+			scanline_buffer = new Uint8Array( ptr_end );
+
+			// read in each successive scanline
+			while ( ( num_scanlines > 0 ) && ( pos < buffer.byteLength ) ) {
+
+				if ( pos + 4 > buffer.byteLength ) {
+
+					return rgbe_error( rgbe_read_error );
+
+				}
+
+				rgbeStart[ 0 ] = buffer[ pos ++ ];
+				rgbeStart[ 1 ] = buffer[ pos ++ ];
+				rgbeStart[ 2 ] = buffer[ pos ++ ];
+				rgbeStart[ 3 ] = buffer[ pos ++ ];
+
+				if ( ( 2 != rgbeStart[ 0 ] ) || ( 2 != rgbeStart[ 1 ] ) || ( ( ( rgbeStart[ 2 ] << 8 ) | rgbeStart[ 3 ] ) != scanline_width ) ) {
+
+					return rgbe_error( rgbe_format_error, "bad rgbe scanline format" );
+
+				}
+
+				// read each of the four channels for the scanline into the buffer
+				// first red, then green, then blue, then exponent
+				ptr = 0;
+				while ( ( ptr < ptr_end ) && ( pos < buffer.byteLength ) ) {
+
+					count = buffer[ pos ++ ];
+					isEncodedRun = count > 128;
+					if ( isEncodedRun ) count -= 128;
+
+					if ( ( 0 === count ) || ( ptr + count > ptr_end ) ) {
+
+						return rgbe_error( rgbe_format_error, "bad scanline data" );
+
+					}
+
+					if ( isEncodedRun ) {
+
+						// a (encoded) run of the same value
+						byteValue = buffer[ pos ++ ];
+						for ( i = 0; i < count; i ++ ) {
+
+							scanline_buffer[ ptr ++ ] = byteValue;
+
+						}
+						//ptr += count;
+
+					} else {
+
+						// a literal-run
+						scanline_buffer.set( buffer.subarray( pos, pos + count ), ptr );
+						ptr += count; pos += count;
+
+					}
+
+				}
+
+
+				// now convert data from buffer into rgba
+				// first red, then green, then blue, then exponent (alpha)
+				l = scanline_width; //scanline_buffer.byteLength;
+				for ( i = 0; i < l; i ++ ) {
+
+					off = 0;
+					data_rgba[ offset ] = scanline_buffer[ i + off ];
+					off += scanline_width; //1;
+					data_rgba[ offset + 1 ] = scanline_buffer[ i + off ];
+					off += scanline_width; //1;
+					data_rgba[ offset + 2 ] = scanline_buffer[ i + off ];
+					off += scanline_width; //1;
+					data_rgba[ offset + 3 ] = scanline_buffer[ i + off ];
+					offset += 4;
+
+				}
+
+				num_scanlines --;
+
+			}
+
+			return data_rgba;
+
+		}
+	;
+
+	var byteArray = new Uint8Array( buffer );
+	byteArray.pos = 0;
+	var rgbe_header_info = RGBE_ReadHeader( byteArray );
+
+	if ( RGBE_RETURN_FAILURE !== rgbe_header_info ) {
+
+		var w = rgbe_header_info.width,
+			h = rgbe_header_info.height,
+			image_rgba_data = RGBE_ReadPixels_RLE( byteArray.subarray( byteArray.pos ), w, h )
+		;
+		if ( RGBE_RETURN_FAILURE !== image_rgba_data ) {
+
+			if ( this.type === UnsignedByteType ) {
+
+				var data = image_rgba_data;
+				var format = RGBEFormat; // handled as THREE.RGBAFormat in shaders
+				var type = UnsignedByteType;
+
+			} else if ( this.type === FloatType ) {
+
+				var RGBEByteToRGBFloat = function ( sourceArray, sourceOffset, destArray, destOffset ) {
+
+					var e = sourceArray[ sourceOffset + 3 ];
+					var scale = Math.pow( 2.0, e - 128.0 ) / 255.0;
+
+					destArray[ destOffset + 0 ] = sourceArray[ sourceOffset + 0 ] * scale;
+					destArray[ destOffset + 1 ] = sourceArray[ sourceOffset + 1 ] * scale;
+					destArray[ destOffset + 2 ] = sourceArray[ sourceOffset + 2 ] * scale;
+
+				};
+
+				var numElements = ( image_rgba_data.length / 4 ) * 3;
+				var floatArray = new Float32Array( numElements );
+
+				for ( var j = 0; j < numElements; j ++ ) {
+
+					RGBEByteToRGBFloat( image_rgba_data, j * 4, floatArray, j * 3 );
+
+				}
+
+				var data = floatArray;
+				var format = RGBFormat;
+				var type = FloatType;
+
+
+			} else {
+
+				console.error( 'THREE.RGBELoader: unsupported type: ', this.type );
+
+			}
+
+			return {
+				width: w, height: h,
+				data: data,
+				header: rgbe_header_info.string,
+				gamma: rgbe_header_info.gamma,
+				exposure: rgbe_header_info.exposure,
+				format: format,
+				type: type
+			};
+
+		}
+
+	}
+
+	return null;
+
+};
+
+RGBELoader.prototype.setType = function ( value ) {
+
+	this.type = value;
+	return this;
+
+};
+
+export { RGBELoader };

+ 4 - 4
examples/webgl_loader_assimp2json.html

@@ -91,8 +91,9 @@
 
 				// load jeep model
 
-				var loader1 = new THREE.AssimpJSONLoader();
-				loader1.load( 'models/assimp/jeep/jeep.assimp.json', function ( object ) {
+				var loader = new THREE.AssimpJSONLoader();
+
+				loader.load( 'models/assimp/jeep/jeep.assimp.json', function ( object ) {
 
 					object.scale.multiplyScalar( 0.2 );
 					scene.add( object );
@@ -101,8 +102,7 @@
 
 				// load interior model
 
-				var loader2 = new THREE.AssimpJSONLoader();
-				loader2.load( 'models/assimp/interior/interior.assimp.json', function ( object ) {
+				loader.load( 'models/assimp/interior/interior.assimp.json', function ( object ) {
 
 					scene.add( object );
 

+ 4 - 0
utils/modularize.js

@@ -32,12 +32,15 @@ var files = [
 	{ path: 'exporters/STLExporter.js', dependencies: [], ignoreList: [] },
 	{ path: 'exporters/TypedGeometryExporter.js', dependencies: [], ignoreList: [] },
 
+	{ path: 'loaders/AssimpJSONLoader.js', dependencies: [], ignoreList: [] },
+	{ path: 'loaders/AssimpLoader.js', dependencies: [], ignoreList: [] },
 	{ path: 'loaders/BabylonLoader.js', dependencies: [], ignoreList: [] },
 	{ path: 'loaders/BVHLoader.js', dependencies: [], ignoreList: [ 'Bones' ] },
 	{ path: 'loaders/ColladaLoader.js', dependencies: [ { name: 'TGALoader', path: 'loaders/TGALoader.js' } ], ignoreList: [] },
 	{ path: 'loaders/DDSLoader.js', dependencies: [], ignoreList: [] },
 	{ path: 'loaders/EXRLoader.js', dependencies: [], ignoreList: [] },
 	{ path: 'loaders/FBXLoader.js', dependencies: [ { name: 'TGALoader', path: 'loaders/TGALoader.js' }, { name: 'NURBSCurve', path: 'curves/NURBSCurve.js' } ], ignoreList: [] },
+	{ path: 'loaders/GCodeLoader.js', dependencies: [], ignoreList: [] },
 	{ path: 'loaders/GLTFLoader.js', dependencies: [], ignoreList: [ 'NoSide', 'Matrix2', 'DDSLoader' ] },
 	{ path: 'loaders/MTLLoader.js', dependencies: [], ignoreList: [ 'BackSide', 'DoubleSide', 'ClampToEdgeWrapping', 'MirroredRepeatWrapping' ] },
 	{ path: 'loaders/OBJLoader.js', dependencies: [], ignoreList: [] },
@@ -45,6 +48,7 @@ var files = [
 	{ path: 'loaders/PDBLoader.js', dependencies: [], ignoreList: [] },
 	{ path: 'loaders/PlayCanvasLoader.js', dependencies: [], ignoreList: [] },
 	{ path: 'loaders/PLYLoader.js', dependencies: [], ignoreList: [ 'Mesh' ] },
+	{ path: 'loaders/RGBELoader.js', dependencies: [], ignoreList: [ 'RGBAFormat' ] },
 	{ path: 'loaders/STLLoader.js', dependencies: [], ignoreList: [ 'Mesh', 'MeshPhongMaterial', 'VertexColors' ] },
 	{ path: 'loaders/SVGLoader.js', dependencies: [], ignoreList: [] },
 	{ path: 'loaders/TGALoader.js', dependencies: [], ignoreList: [] },