From 895e434cfead3c7aa049a20be7bd27ae19c0f505 Mon Sep 17 00:00:00 2001 From: David Cormack Date: Mon, 8 May 2017 21:11:37 +0100 Subject: [PATCH 1/2] Added support for Binary Object/Material (BOM) file format. --- README.md | 1 + dist/UltimateLoader.js | 759 +++++++++++++++++++++++++++++++++++- dist/UltimateLoader.min.js | 9 +- dist/UltimateLoader2.js | 759 +++++++++++++++++++++++++++++++++++- dist/UltimateLoader2.min.js | 9 +- src/UltimateLoader.js | 25 ++ src/UltimateLoader2.js | 25 ++ 7 files changed, 1573 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index a44cf02..fc83dc9 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ Currently accepted object file types: * .json * .dae * .gltf +* .bom Currently accepted image file types (will be mapped to plane): * .jpeg / .jpg diff --git a/dist/UltimateLoader.js b/dist/UltimateLoader.js index 6f56fe8..cd68b57 100644 --- a/dist/UltimateLoader.js +++ b/dist/UltimateLoader.js @@ -209,6 +209,10 @@ var UltimateLoader = UltimateLoader || {}; case "jpeg": loadImage(file); break; + + case "bom": + loadBOM(file); + break; default: console.log("UltimateLoader: File extension -" + file.ext + "- not recognized! Object -" + file.name + "- did not load."); @@ -294,6 +298,27 @@ var UltimateLoader = UltimateLoader || {}; }); } + /** + * loadBOM() + * .bom file found, attempt to load the .bom. + * + */ + function loadBOM(file) + { + var bom = file.name + '.bom'; + + var bomLoader = new THREE.BOMLoader(); + + bomLoader.setTexturePath(file.baseUrl); + bomLoader.setCrossOrigin(crossOrigin); + + bomLoader.load(bom, function(object) + { + file.object = object; + handleOnLoad(file); + }, onProgress, onError); + } + /** * loadJSON() * .json file found, attempt to load it. @@ -9242,4 +9267,736 @@ THREE.GLTFLoader = ( function () { return GLTFLoader; -} )(); \ No newline at end of file +} )(); + +/** + * BOM (Binary Object/Material) provides a subset of Wavefront OBJ and MTL functionality to + * load indexed triangulated geometry and basic materials from a compact binary representation. + * + * @author Genesis / https://github.com/NGenesis/ + */ + +THREE.BOMLoader = function ( manager ) { + + this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; + +}; + +THREE.BOMLoader.prototype = { + + constructor: THREE.BOMLoader, + + load: function ( url, onLoad, onProgress, onError ) { + + var scope = this; + + var loader = THREE.FileLoader ? new THREE.FileLoader( this.manager ) : new THREE.XHRLoader( this.manager ); + loader.setPath( this.path ); + loader.setResponseType( 'arraybuffer' ); + loader.load( url, function ( buffer ) { + + onLoad( scope.parse( buffer ) ); + + }, onProgress, onError ); + + }, + + setPath: function ( value ) { + + this.path = value; + + }, + + setTexturePath: function ( value ) { + + this.texturePath = value; + + }, + + setCrossOrigin: function ( value ) { + + this.crossOrigin = value; + + }, + + setDebug: function ( value ) { + + this.debug = value; + + }, + + setPerfTimer: function ( value ) { + + this.performanceTimer = value; + + }, + + setResponseType: function ( value ) { + + this.responseType = value; + + }, + + parse: function ( buffer ) { + + if ( this.performanceTimer ) console.time( 'BOMLoader' ); + + var FaceCulling = { + + NONE: 0, + FRONT: 1, + BACK: 2, + ALL: 3 + + }, + + FileDataAttribute = { + + NONE: 1 << 0, + MATERIAL_LIBRARY: 1 << 1 + + }, + + AssetDataAttribute = { + + NONE: 1 << 0, + NAME: 1 << 1 + + }, + + GroupDataAttribute = { + + NONE: 1 << 0, + NAME: 1 << 1, + INDEX: 1 << 2, + SMOOTHING: 1 << 3, + MATERIAL: 1 << 4 + + }, + + ObjectDataAttribute = { + + NONE: 1 << 0, + GEOMETRY: 1 << 1 + + }, + + GeometryDataAttribute = { + + NONE: 1 << 0, + NORMAL: 1 << 1, + UV1: 1 << 2, + UV2: 1 << 3 + + }, + + MaterialDataAttribute = { + + NONE: 1 << 0, + ILLUMINATION_MODEL: 1 << 1, + SPECULAR_EXPONENT: 1 << 2, + OPTICAL_DENSITY: 1 << 3, + DISSOLVE: 1 << 4, + TRANSMISSION_FILTER: 1 << 5, + AMBIENT_REFLECTANCE: 1 << 6, + DIFFUSE_REFLECTANCE: 1 << 7, + SPECULAR_REFLECTANCE: 1 << 8, + EMISSIVE_REFLECTANCE: 1 << 9, + AMBIENT_MAP: 1 << 10, + DIFFUSE_MAP: 1 << 11, + SPECULAR_MAP: 1 << 12, + EMISSIVE_MAP: 1 << 13, + DISSOLVE_MAP: 1 << 14, + BUMP_MAP: 1 << 15, + DISPLACEMENT_MAP: 1 << 16, + FACE_CULLING: 1 << 17, + LIGHT_MAP: 1 << 18 + + }, + + MapDataAttribute = { + + NONE: 1 << 0, + PATH: 1 << 1, + SCALE: 1 << 2, + OFFSET: 1 << 3, + BUMP_SCALE: 1 << 4, + DISPLACEMENT_SCALE: 1 << 5, + LIGHTMAP_INTENSITY: 1 << 6 + + }; + + var view = new DataView( buffer ), pos = 0, isAssetArray = ( this.responseType === 'array' ), assets = ( isAssetArray ? [] : new THREE.Group() ); + + function readUint8 () { + + var value = view.getUint8( pos ); + pos += Uint8Array.BYTES_PER_ELEMENT; + return value; + + } + + function readUint16 () { + + var value = view.getUint16( pos, true ); + pos += Uint16Array.BYTES_PER_ELEMENT; + return value; + + } + + function readUint32 () { + + var value = view.getUint32( pos, true ); + pos += Uint32Array.BYTES_PER_ELEMENT; + return value; + + } + + function readFloat32 () { + + var value = view.getFloat32( pos, true ); + pos += Float32Array.BYTES_PER_ELEMENT; + return value; + + } + + function readString ( length ) { + + var value = String.fromCharCode.apply( null, ( length > 0 ) ? new Uint8Array( view.buffer, pos, length ) : new Uint8Array() ); + pos += Uint8Array.BYTES_PER_ELEMENT * length; + return value; + + } + + function readUint16Array ( length ) { + + if ( ( pos % Uint16Array.BYTES_PER_ELEMENT ) === 0 ) { + + // Aligned Access + var value = new Uint16Array( view.buffer, pos, length ); + pos += Uint16Array.BYTES_PER_ELEMENT * length; + return value; + + } + + // Unaligned Access + var value = new Uint16Array( length ); + for ( var i = 0; i < length; ++i, pos += Uint16Array.BYTES_PER_ELEMENT ) value[ i ] = view.getUint16( pos, true ); + return value; + + } + + function readFloat32Array ( length ) { + + if ( ( pos % Float32Array.BYTES_PER_ELEMENT ) === 0 ) { + + // Aligned Access + var value = new Float32Array( view.buffer, pos, length ); + pos += Float32Array.BYTES_PER_ELEMENT * length; + return value; + + } + + // Unaligned Access + var value = new Float32Array( length ); + for ( var i = 0; i < length; ++i, pos += Float32Array.BYTES_PER_ELEMENT ) value[ i ] = view.getFloat32( pos, true ); + return value; + + } + + var scope = this; + + function resolveURL ( url ) { + + if ( typeof url !== 'string' || url === '' ) return ''; + + // Absolute URL + if ( /^https?:\/\//i.test( url ) ) return url; + + var absoluteUrl = new URL(( scope.texturePath || scope.path || '' ) + url, location.href.substring( 0, location.href.lastIndexOf( '/' ) + 1 )); + return absoluteUrl.toString(); + + } + + function loadTexture ( url ) { + + url = resolveURL( url ); + var texture; + + if ( altspace && altspace.inClient ) { + + // Defer Texture Image Loading To Native Altspace Client + texture = new THREE.Texture( { src: url } ); + + } else { + + var loader = THREE.Loader.Handlers.get( url ); + if ( loader === null ) loader = new THREE.TextureLoader( scope.manager ); + loader.setCrossOrigin( scope.crossOrigin ); + texture = loader.load( url ); + + } + + texture.side = THREE.FrontSide; + texture.wrapS = texture.wrapT = THREE.RepeatWrapping; + + return texture; + + } + + // File Signature + var fileSignature = readString( 3 ); + if ( this.debug ) console.log( 'File Signature', fileSignature ); + + // Version + var version = readUint8(); + if ( this.debug ) console.log( 'Version', version ); + + // File Data Attributes + var fileAttributes = readUint16(); + if ( this.debug ) { + + console.log( + + 'FileAttributes:', '\n', + 'Material Library', ( objectAttributes & FileDataAttribute.MATERIAL_LIBRARY ) ? true : false + + ); + + } + + // Materials + var materials = []; + if ( fileAttributes & FileDataAttribute.MATERIAL_LIBRARY ) { + + // Material Count + var materialCount = readUint16(); + if ( this.debug ) console.log( 'Material Count', materialCount ); + + for ( var i = 0; i < materialCount; ++i ) { + + // Material Data Attributes + var materialAttributes = readUint32(); + if ( this.debug ) { + + console.log( + + 'MaterialAttributes:', '\n', + 'Illumination Model', ( materialAttributes & MaterialDataAttribute.ILLUMINATION_MODEL ) ? true : false, '\n', + 'Specular Exponent', ( materialAttributes & MaterialDataAttribute.SPECULAR_EXPONENT ) ? true : false, '\n', + 'Optical Density', ( materialAttributes & MaterialDataAttribute.OPTICAL_DENSITY ) ? true : false, '\n', + 'Dissolve', ( materialAttributes & MaterialDataAttribute.DISSOLVE ) ? true : false, '\n', + 'Transmission Filter', ( materialAttributes & MaterialDataAttribute.TRANSMISSION_FILTER ) ? true : false, '\n', + 'Ambient Reflectance', ( materialAttributes & MaterialDataAttribute.AMBIENT_REFLECTANCE ) ? true : false, '\n', + 'Diffuse Reflectance', ( materialAttributes & MaterialDataAttribute.DIFFUSE_REFLECTANCE ) ? true : false, '\n', + 'Specular Reflectance', ( materialAttributes & MaterialDataAttribute.SPECULAR_REFLECTANCE ) ? true : false, '\n', + 'Ambient Map', ( materialAttributes & MaterialDataAttribute.AMBIENT_MAP ) ? true : false, '\n', + 'Diffuse Map', ( materialAttributes & MaterialDataAttribute.DIFFUSE_MAP ) ? true : false, '\n', + 'Specular Map', ( materialAttributes & MaterialDataAttribute.SPECULAR_MAP ) ? true : false, '\n', + 'Dissolve Map', ( materialAttributes & MaterialDataAttribute.DISSOLVE_MAP ) ? true : false, '\n', + 'Bump Map', ( materialAttributes & MaterialDataAttribute.BUMP_MAP ) ? true : false, '\n', + 'Displacement Map', ( materialAttributes & MaterialDataAttribute.DISPLACEMENT_MAP ) ? true : false, '\n', + 'Face Culling', ( materialAttributes & MaterialDataAttribute.FACE_CULLING ) ? true : false, '\n', + 'Light Map', ( materialAttributes & MaterialDataAttribute.LIGHT_MAP ) ? true : false + + ); + + } + + var params = {}; + + // Material Name + params.name = readString( readUint16() ); + if ( this.debug ) console.log( 'Material Name', params.name ); + + // Illumination Model (illum) + if ( materialAttributes & MaterialDataAttribute.ILLUMINATION_MODEL ) { + + readUint8(); + // Not supported + + } + + // Specular Exponent (Ns) + if ( materialAttributes & MaterialDataAttribute.SPECULAR_EXPONENT ) { + + params.shininess = readFloat32(); + if ( this.debug ) console.log( 'Specular Exponent', params.shininess ); + + } + + // Optical Density (Ni) + if ( materialAttributes & MaterialDataAttribute.OPTICAL_DENSITY ) { + + readFloat32(); + // Not supported + + } + + // Dissolve (d / [1 - Tr]) + if ( materialAttributes & MaterialDataAttribute.DISSOLVE ) { + + params.opacity = readFloat32(); + params.transparent = true; + if ( this.debug ) console.log( 'Dissolve', params.opacity ); + + } + + // Transmission Filter (Tf) + if ( materialAttributes & MaterialDataAttribute.TRANSMISSION_FILTER ) { + + readFloat32(), readFloat32(), readFloat32(); + // Not supported + + } + + // Ambient Reflectance (Ka) + if ( materialAttributes & MaterialDataAttribute.AMBIENT_REFLECTANCE ) { + + readFloat32(), readFloat32(), readFloat32(); + // Assumes ambient and diffuse are linked + + } + + // Diffuse Reflectance (Kd) + if ( materialAttributes & MaterialDataAttribute.DIFFUSE_REFLECTANCE ) { + + params.color = new THREE.Color( readFloat32(), readFloat32(), readFloat32() ); + if ( this.debug ) console.log( 'Diffuse Reflectance', params.color ); + + } + + // Specular Reflectance (Ks) + if ( materialAttributes & MaterialDataAttribute.SPECULAR_REFLECTANCE ) { + + params.specular = new THREE.Color( readFloat32(), readFloat32(), readFloat32() ); + if ( this.debug ) console.log( 'Specular Reflectance', params.specular ); + + } + + // Emissive Reflectance (Ke) + if ( materialAttributes & MaterialDataAttribute.EMISSIVE_REFLECTANCE ) { + + params.emissive = new THREE.Color( readFloat32(), readFloat32(), readFloat32() ); + if ( this.debug ) console.log( 'Emissive Reflectance', params.emissive ); + + } + + // Ambient Map (map_Ka) + if ( materialAttributes & MaterialDataAttribute.AMBIENT_MAP ) { + + var mapDataAttributes = readUint16(); + if ( mapDataAttributes & MapDataAttribute.PATH ) readString( readUint16() ); + if ( mapDataAttributes & MapDataAttribute.SCALE ) readFloat32(), readFloat32(); + if ( mapDataAttributes & MapDataAttribute.OFFSET ) readFloat32(), readFloat32(); + // Assumes ambient and diffuse are linked + + } + + // Diffuse Map (map_Kd) + if ( materialAttributes & MaterialDataAttribute.DIFFUSE_MAP ) { + + var mapDataAttributes = readUint16(); + var map = loadTexture( ( mapDataAttributes & MapDataAttribute.PATH ) ? readString( readUint16() ) : '' ); + if ( mapDataAttributes & MapDataAttribute.SCALE ) map.repeat.set( readFloat32(), readFloat32() ); + if ( mapDataAttributes & MapDataAttribute.OFFSET ) map.offset.set( readFloat32(), readFloat32() ); + params.map = map; + if ( this.debug && ( mapDataAttributes & MapDataAttribute.PATH ) ) console.log( 'Diffuse Map', map ); + + } + + // Specular Map (map_Ks) + if ( materialAttributes & MaterialDataAttribute.SPECULAR_MAP ) { + + var mapDataAttributes = readUint16(); + var map = loadTexture( ( mapDataAttributes & MapDataAttribute.PATH ) ? readString( readUint16() ) : '' ); + if ( mapDataAttributes & MapDataAttribute.SCALE ) map.repeat.set( readFloat32(), readFloat32() ); + if ( mapDataAttributes & MapDataAttribute.OFFSET ) map.offset.set( readFloat32(), readFloat32() ); + params.specularMap = map; + + } + + // Emissive Map (map_Ke) + if ( materialAttributes & MaterialDataAttribute.EMISSIVE_MAP ) { + + var mapDataAttributes = readUint16(); + var map = loadTexture( ( mapDataAttributes & MapDataAttribute.PATH ) ? readString( readUint16() ) : '' ); + if ( mapDataAttributes & MapDataAttribute.SCALE ) map.repeat.set( readFloat32(), readFloat32() ); + if ( mapDataAttributes & MapDataAttribute.OFFSET ) map.offset.set( readFloat32(), readFloat32() ); + params.emissiveMap = map; + + } + + // Dissolve Map (map_d) + if ( materialAttributes & MaterialDataAttribute.DISSOLVE_MAP ) { + + var mapDataAttributes = readUint16(); + var map = loadTexture( ( mapDataAttributes & MapDataAttribute.PATH ) ? readString( readUint16() ) : '' ); + if ( mapDataAttributes & MapDataAttribute.SCALE ) map.repeat.set( readFloat32(), readFloat32() ); + if ( mapDataAttributes & MapDataAttribute.OFFSET ) map.offset.set( readFloat32(), readFloat32() ); + params.alphaMap = map; + params.transparent = true; + + } + + // Bump Map (map_bump / bump) + if ( materialAttributes & MaterialDataAttribute.BUMP_MAP ) { + + var mapDataAttributes = readUint16(); + var map = loadTexture( ( mapDataAttributes & MapDataAttribute.PATH ) ? readString( readUint16() ) : '' ); + if ( mapDataAttributes & MapDataAttribute.SCALE ) map.repeat.set( readFloat32(), readFloat32() ); + if ( mapDataAttributes & MapDataAttribute.OFFSET ) map.offset.set( readFloat32(), readFloat32() ); + if ( mapDataAttributes & MapDataAttribute.BUMP_SCALE ) params.bumpScale = readFloat32(); + params.bumpMap = map; + + } + + // Displacement Map (map_disp / disp) + if ( materialAttributes & MaterialDataAttribute.DISPLACEMENT_MAP ) { + + var mapDataAttributes = readUint16(); + var map = loadTexture( ( mapDataAttributes & MapDataAttribute.PATH ) ? readString( readUint16() ) : '' ); + if ( mapDataAttributes & MapDataAttribute.SCALE ) map.repeat.set( readFloat32(), readFloat32() ); + if ( mapDataAttributes & MapDataAttribute.OFFSET ) map.offset.set( readFloat32(), readFloat32() ); + if ( mapDataAttributes & MapDataAttribute.DISPLACEMENT_SCALE ) params.displacementScale = readFloat32(); + params.displacementMap = map; + + } + + // Face Culling (cull_face) + if ( materialAttributes & MaterialDataAttribute.FACE_CULLING ) { + + var faceCulling = readUint8(); + if ( faceCulling === FaceCulling.ALL ) params.visible = false; + else if ( faceCulling === FaceCulling.FRONT ) params.side = THREE.BackSide; + else if ( faceCulling === FaceCulling.BACK ) params.side = THREE.FrontSide; + else params.side = THREE.DoubleSide; + + } + + // Light Map (lightmap) + if ( materialAttributes & MaterialDataAttribute.LIGHT_MAP ) { + + var mapDataAttributes = readUint16(); + var map = loadTexture( ( mapDataAttributes & MapDataAttribute.PATH ) ? readString( readUint16() ) : '' ); + if ( mapDataAttributes & MapDataAttribute.SCALE ) map.repeat.set( readFloat32(), readFloat32() ); + if ( mapDataAttributes & MapDataAttribute.OFFSET ) map.offset.set( readFloat32(), readFloat32() ); + if ( mapDataAttributes & MapDataAttribute.LIGHTMAP_INTENSITY ) params.lightMapIntensity = readFloat32(); + params.lightMap = map; + + } + + var material = new THREE.MeshPhongMaterial( params ); + materials.push( material ); + + } + + } + + // Asset Count + var assetCount = readUint16(); + if ( this.debug ) console.log( 'Asset Count', assetCount ); + + for ( var a = 0; a < assetCount; ++a ) { + + // Asset Data Attributes + var assetAttributes = readUint16(); + + if ( this.debug ) { + + console.log( + + 'AssetAttributes:', '\n', + 'Name', ( assetAttributes & AssetDataAttribute.NAME ) ? true : false + + ); + + } + + var asset = assets; + if ( isAssetArray ) { + + asset = new THREE.Group(); + assets.push( asset ); + + } + + // Asset Name + if ( assetAttributes & AssetDataAttribute.NAME ) { + + var assetName = readString( readUint16() ); + if ( this.debug ) console.log( 'Asset Name', assetName ); + if ( !isAssetArray ) asset.name = assetName; + + } + + // Object Count + var objectCount = readUint16(); + if ( this.debug ) console.log( 'Object Count', objectCount ); + + for ( var i = 0; i < objectCount; ++i ) { + + // Object Data Attributes + var objectAttributes = readUint16(); + + if ( this.debug ) { + + console.log( + + 'ObjectAttributes:', '\n', + 'Geometry', ( objectAttributes & ObjectDataAttribute.GEOMETRY ) ? true : false + + ); + + } + + var vertices = {}; + if ( objectAttributes & ObjectDataAttribute.GEOMETRY ) { + + // Geometry Data Attributes + var geometryAttributes = readUint16(); + if ( this.debug ) { + + console.log( + + 'GeometryAttributes:', '\n', + 'Normal', ( geometryAttributes & GeometryDataAttribute.NORMAL ) ? true : false, '\n', + 'UV1', ( geometryAttributes & GeometryDataAttribute.UV1 ) ? true : false, '\n', + 'UV2', ( geometryAttributes & GeometryDataAttribute.UV2 ) ? true : false + + ); + + } + + // Vertex Count + var vertexCount = readUint32(); + if ( this.debug ) console.log( 'Vertex Count', vertexCount ); + + // Vertex Positions + vertices.positions = readFloat32Array( vertexCount * 3 ); + + // Vertex Normals + if ( geometryAttributes & GeometryDataAttribute.NORMAL ) vertices.normals = readFloat32Array( vertexCount * 3 ); + + // Vertex UVs + if ( geometryAttributes & GeometryDataAttribute.UV1 ) vertices.uvs = readFloat32Array( vertexCount * 2 ); + if ( geometryAttributes & GeometryDataAttribute.UV2 ) vertices.uvs2 = readFloat32Array( vertexCount * 2 ); + + } + + // Group Count + var groupCount = readUint16(); + if ( this.debug ) console.log( 'Group Count', groupCount ); + + for ( var j = 0; j < groupCount; ++j ) { + + // Group Data Attributes + var groupAttributes = readUint16(); + if ( this.debug ) { + + console.log( + + 'GroupAttributes:', '\n', + 'Index', ( groupAttributes & GroupDataAttribute.INDEX ) ? true : false, '\n', + 'Smoothing', ( groupAttributes & GroupDataAttribute.SMOOTHING ) ? true : false, '\n', + 'Material', ( groupAttributes & GroupDataAttribute.MATERIAL ) ? true : false + + ); + + } + + // Group Name + var groupName; + if ( groupAttributes & GroupDataAttribute.NAME ) { + + groupName = readString( readUint16() ); + if ( this.debug ) console.log( 'Group Name', groupName ); + + } + + if ( objectAttributes & ObjectDataAttribute.GEOMETRY ) { + + // Indices + var indices; + if ( groupAttributes & GroupDataAttribute.INDEX ) { + + // Index Count + var indexCount = readUint32(); + if ( this.debug ) console.log( 'Index Count', indexCount ); + + // Indices + indices = readUint16Array( indexCount ); + + } + + // Smoothing + var smoothing = ( groupAttributes & GroupDataAttribute.SMOOTHING ) ? readUint8() : 0; + if ( this.debug && ( groupAttributes & GroupDataAttribute.SMOOTHING ) ) console.log( 'Smoothing', smoothing ); + + var geometry = new THREE.BufferGeometry(); + if ( vertices.positions ) geometry.addAttribute( 'position', new THREE.BufferAttribute( vertices.positions, 3 ) ); + vertices.normals ? geometry.addAttribute( 'normal', new THREE.BufferAttribute( vertices.normals, 3 ) ) : geometry.computeVertexNormals(); + if ( vertices.uvs ) geometry.addAttribute( 'uv', new THREE.BufferAttribute( vertices.uvs, 2 ) ); + if ( vertices.uvs2 ) geometry.addAttribute( 'uv2', new THREE.BufferAttribute( vertices.uvs2, 2 ) ); + if ( indices ) geometry.setIndex( new THREE.BufferAttribute( indices, 1 ) ); + geometry.addGroup( 0, 1, 0 ); + + var material; + if ( groupAttributes & GroupDataAttribute.MATERIAL ) { + + // Material ID + var materialId = readUint16(); + material = materials[ materialId ].clone() || new THREE.MeshPhongMaterial(); + material.shading = ( smoothing > 0 ) ? THREE.SmoothShading : THREE.FlatShading; + if ( this.debug ) console.log( 'Group Material', materialId, material ); + + } + + var mesh = new THREE.Mesh( geometry, material ); + if ( groupName ) mesh.name = groupName; + asset.add( mesh ); + + } + + } + + } + + } + + if ( this.performanceTimer ) console.timeEnd( 'BOMLoader' ); + + return assets; + + } + +}; + +THREE.BOMLoaderUtil = THREE.BOMLoaderUtil || {}; +THREE.BOMLoaderUtil.multiload = function ( requests, onComplete ) { + + requests = ( requests.constructor === Array ) ? requests : [ requests ]; + var requestCount = requests.length; + var responses = []; + + function loadRequest ( index, request ) { + + var loader = new THREE.BOMLoader(); + loader.setTexturePath( request.url.split( '/' ).slice( 0, -1 ).join( '/' ) + '/' ); + if ( request.debug !== undefined ) loader.setDebug( request.debug ); + if ( request.timer !== undefined ) loader.setPerfTimer( request.timer ); + if ( request.crossOrigin !== undefined ) loader.setCrossOrigin( request.crossOrigin ); + if ( request.responseType !== undefined ) loader.setResponseType( request.responseType ); + loader.load( request.url, function ( object ) { + + request.object = object; + responses[ index ] = request; + if ( --requestCount <= 0 ) onComplete( responses ); + + } ); + + } + + for ( var i = 0; i < requests.length; ++i ) loadRequest( i, requests[ i ] ); + +}; diff --git a/dist/UltimateLoader.min.js b/dist/UltimateLoader.min.js index ee0d629..e9e41fc 100644 --- a/dist/UltimateLoader.min.js +++ b/dist/UltimateLoader.min.js @@ -1,6 +1,3 @@ -var UltimateLoader=UltimateLoader||{};!function(e){"use strict";function a(e,a,t){m.push([e,a,t])}function t(){if(E>m.length-1)return m=[],void(E=0);var e=m[E];E++,o(e[0],e[1],e[2])}function n(){0==E&&t()}function o(e,a,n){var o=r(i(e));switch(o.url=e,o.callback=a,null!=n&&(o.i=n),o.ext){case"obj":l(o);break;case"json":c(o);break;case"dae":s(o);break;case"gltf":d(o);break;case"glb":d(o);break;case"fbx":loadFBX(o);break;case"drc":loadDRACO(o);break;case"png":u(o);break;case"jpg":u(o);break;case"jpeg":u(o);break;default:console.log("UltimateLoader: File extension -"+o.ext+"- not recognized! Object -"+o.name+"- did not load."),t()}}function r(e){var a=e.slice(0,e.lastIndexOf("/")+1),t=e.substr(e.lastIndexOf("/")+1),n=t.split("."),o=n[0],r=n[n.length-1].toLowerCase(),i={name:o,ext:r,baseUrl:a};return i}function i(e,a){if("string"!=typeof e||""===e)return"";if(/^(https?:)?\/\//i.test(e))return e;if(/^data:.*,.*$/i.test(e))return e;var t=new URL((a||"")+e,location.href.substring(0,location.href.lastIndexOf("/")+1));return t.toString()}function l(e){var a=e.name+".obj",t=e.name+".mtl",n=new THREE.MTLLoader;n.setPath(e.baseUrl),n.setTexturePath?n.setTexturePath(e.baseUrl):n.setBaseUrl(e.baseUrl),n.setCrossOrigin(T),n.load(t,function(t){t.preload();var n=new THREE.OBJLoader;n.setMaterials(t),n.setPath(e.baseUrl),n.load(a,function(a){e.object=a,g(e)},f,b)})}function c(e){var a=new THREE.ObjectLoader;a.load(e.url,function(a){e.object=a,g(e)},f,b)}function s(e){var a=new THREE.ColladaLoader;a.load(e.url,function(a){var t=a.scene;e.object=t,g(e)},f,b)}function u(a){var t=new THREE.TextureLoader;t.load(a.url,function(t){var n=t;if(e.loadImagesOnPlane){var o=t.image.naturalHeight/t.image.naturalWidth*e.imageSize,r=new THREE.PlaneGeometry(e.imageSize,o,e.imageSize),i=new THREE.MeshBasicMaterial({map:t,side:THREE.DoubleSide}),l=new THREE.Mesh(r,i);n=l}a.object=n,g(a)},f,b)}function d(e){var a=new THREE.GLTFLoader;a.load(e.url,function(a){var t=a.scene;e.object=t,g(e)},f,b)}function f(e){}function b(e){console.log("There was an error loading your object")}function g(a){null!=a.i?a.callback(a):a.callback(a.object),e.useQueue&&t(),console.log("UltimateLoader: Object "+a.name+" loaded!")}var m=[],E=0,T="anonymous";e.useQueue=!1,e.imageSize=32,e.loadImagesOnPlane=!1,e.load=function(t,r){e.useQueue?(a(t,r),n()):o(t,r)},e.multiload=function(t,r){console.time("Time");for(var i=[],l=0,c=function(e){i[e.i]=e.object,l++,l==t.length&&(r(i),console.timeEnd("Time"))},s=0;s=0?o.substring(0,n):o;p=p.toLowerCase();var h=n>=0?o.substring(n+1):"";if(h=h.trim(),"newmtl"===p)e={name:h},s[h]=e;else if(e)if("ka"===p||"kd"===p||"ks"===p){var l=h.split(r,3);e[p]=[parseFloat(l[0]),parseFloat(l[1]),parseFloat(l[2])]}else e[p]=h}}var c=new THREE.MTLLoader.MaterialCreator(this.texturePath||this.path,this.materialOptions);return c.setCrossOrigin(this.crossOrigin),c.setManager(this.manager),c.setMaterials(s),c}},THREE.MTLLoader.MaterialCreator=function(t,a){this.baseUrl=t||"",this.options=a,this.materialsInfo={},this.materials={},this.materialsArray=[],this.nameLookup={},this.side=this.options&&this.options.side?this.options.side:THREE.FrontSide,this.wrap=this.options&&this.options.wrap?this.options.wrap:THREE.RepeatWrapping},THREE.MTLLoader.MaterialCreator.prototype={constructor:THREE.MTLLoader.MaterialCreator,setCrossOrigin:function(t){this.crossOrigin=t},setManager:function(t){this.manager=t},setMaterials:function(t){this.materialsInfo=this.convert(t),this.materials={},this.materialsArray=[],this.nameLookup={}},convert:function(t){if(!this.options)return t;var a={};for(var e in t){var r=t[e],s={};a[e]=s;for(var i in r){var o=!0,n=r[i],p=i.toLowerCase();switch(p){case"kd":case"ka":case"ks":this.options&&this.options.normalizeRGB&&(n=[n[0]/255,n[1]/255,n[2]/255]),this.options&&this.options.ignoreZeroRGBs&&0===n[0]&&0===n[1]&&0===n[2]&&(o=!1)}o&&(s[p]=n)}}return a},preload:function(){for(var t in this.materialsInfo)this.create(t)},getIndex:function(t){return this.nameLookup[t]},getAsArray:function(){var t=0;for(var a in this.materialsInfo)this.materialsArray[t]=this.create(a),this.nameLookup[a]=t,t++;return this.materialsArray},create:function(t){return void 0===this.materials[t]&&this.createMaterial_(t),this.materials[t]},createMaterial_:function(t){function a(t,a){return"string"!=typeof a||""===a?"":/^https?:\/\//i.test(a)?a:t+a}function e(t,e){if(!i[t]){var s=r.getTextureParams(e,i),o=r.loadTexture(a(r.baseUrl,s.url));o.repeat.copy(s.scale),o.offset.copy(s.offset),o.wrapS=r.wrap,o.wrapT=r.wrap,i[t]=o}}var r=this,s=this.materialsInfo[t],i={name:t,side:this.side};for(var o in s){var n=s[o];if(""!==n)switch(o.toLowerCase()){case"kd":i.color=(new THREE.Color).fromArray(n);break;case"ks":i.specular=(new THREE.Color).fromArray(n);break;case"map_kd":e("map",n);break;case"map_ks":e("specularMap",n);break;case"map_bump":case"bump":e("bumpMap",n);break;case"ns":i.shininess=parseFloat(n);break;case"d":n<1&&(i.opacity=n,i.transparent=!0);break;case"Tr":n>0&&(i.opacity=1-n,i.transparent=!0)}}return this.materials[t]=new THREE.MeshPhongMaterial(i),this.materials[t]},getTextureParams:function(t,a){var e,r={scale:new THREE.Vector2(1,1),offset:new THREE.Vector2(0,0)},s=t.split(/\s+/);return e=s.indexOf("-bm"),e>=0&&(a.bumpScale=parseFloat(s[e+1]),s.splice(e,2)),e=s.indexOf("-s"),e>=0&&(r.scale.set(parseFloat(s[e+1]),parseFloat(s[e+2])),s.splice(e,4)),e=s.indexOf("-o"),e>=0&&(r.offset.set(parseFloat(s[e+1]),parseFloat(s[e+2])),s.splice(e,4)),r.url=s.join(" ").trim(),r},loadTexture:function(t,a,e,r,s){var i;if(altspace&&altspace.inClient)i=new THREE.Texture({src:t});else{var o=THREE.Loader.Handlers.get(t),n=void 0!==this.manager?this.manager:THREE.DefaultLoadingManager;null===o&&(o=new THREE.TextureLoader(n)),o.setCrossOrigin&&o.setCrossOrigin(this.crossOrigin),i=o.load(t,e,r,s)}return void 0!==a&&(i.mapping=a),i}}; -THREE.OBJLoader=function(e){this.manager=void 0!==e?e:THREE.DefaultLoadingManager,this.materials=null,this.regexp={vertex_pattern:/^v\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,normal_pattern:/^vn\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,uv_pattern:/^vt\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,face_vertex:/^f\s+(-?\d+)\s+(-?\d+)\s+(-?\d+)(?:\s+(-?\d+))?/,face_vertex_uv:/^f\s+(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)(?:\s+(-?\d+)\/(-?\d+))?/,face_vertex_uv_normal:/^f\s+(-?\d+)\/(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\/(-?\d+)(?:\s+(-?\d+)\/(-?\d+)\/(-?\d+))?/,face_vertex_normal:/^f\s+(-?\d+)\/\/(-?\d+)\s+(-?\d+)\/\/(-?\d+)\s+(-?\d+)\/\/(-?\d+)(?:\s+(-?\d+)\/\/(-?\d+))?/,object_pattern:/^[og]\s*(.+)?/,smoothing_pattern:/^s\s+(\d+|on|off)/,material_library_pattern:/^mtllib /,material_use_pattern:/^usemtl /}},THREE.OBJLoader.prototype={constructor:THREE.OBJLoader,load:function(e,t,r,a){var i=this,s=new THREE.FileLoader(i.manager);s.setPath(this.path),s.load(e,function(e){t(i.parse(e))},r,a)},setPath:function(e){this.path=e},setMaterials:function(e){this.materials=e},_createParserState:function(){var e={objects:[],object:{},vertices:[],normals:[],uvs:[],materialLibraries:[],startObject:function(e,t){if(this.object&&this.object.fromDeclaration===!1)return this.object.name=e,void(this.object.fromDeclaration=t!==!1);var r=this.object&&"function"==typeof this.object.currentMaterial?this.object.currentMaterial():void 0;if(this.object&&"function"==typeof this.object._finalize&&this.object._finalize(!0),this.object={name:e||"",fromDeclaration:t!==!1,geometry:{vertices:[],normals:[],uvs:[]},materials:[],smooth:!0,startMaterial:function(e,t){var r=this._finalize(!1);r&&(r.inherited||r.groupCount<=0)&&this.materials.splice(r.index,1);var a={index:this.materials.length,name:e||"",mtllib:Array.isArray(t)&&t.length>0?t[t.length-1]:"",smooth:void 0!==r?r.smooth:this.smooth,groupStart:void 0!==r?r.groupEnd:0,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(e){var t={index:"number"==typeof e?e:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return t.clone=this.clone.bind(t),t}};return this.materials.push(a),a},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(e){var t=this.currentMaterial();if(t&&t.groupEnd===-1&&(t.groupEnd=this.geometry.vertices.length/3,t.groupCount=t.groupEnd-t.groupStart,t.inherited=!1),e&&this.materials.length>1)for(var r=this.materials.length-1;r>=0;r--)this.materials[r].groupCount<=0&&this.materials.splice(r,1);return e&&0===this.materials.length&&this.materials.push({name:"",smooth:this.smooth}),t}},r&&r.name&&"function"==typeof r.clone){var a=r.clone(0);a.inherited=!0,this.object.materials.push(a)}this.objects.push(this.object)},finalize:function(){this.object&&"function"==typeof this.object._finalize&&this.object._finalize(!0)},parseVertexIndex:function(e,t){var r=parseInt(e,10);return 3*(r>=0?r-1:r+t/3)},parseNormalIndex:function(e,t){var r=parseInt(e,10);return 3*(r>=0?r-1:r+t/3)},parseUVIndex:function(e,t){var r=parseInt(e,10);return 2*(r>=0?r-1:r+t/2)},addVertex:function(e,t,r){var a=this.vertices,i=this.object.geometry.vertices;i.push(a[e+0]),i.push(a[e+1]),i.push(a[e+2]),i.push(a[t+0]),i.push(a[t+1]),i.push(a[t+2]),i.push(a[r+0]),i.push(a[r+1]),i.push(a[r+2])},addVertexLine:function(e){var t=this.vertices,r=this.object.geometry.vertices;r.push(t[e+0]),r.push(t[e+1]),r.push(t[e+2])},addNormal:function(e,t,r){var a=this.normals,i=this.object.geometry.normals;i.push(a[e+0]),i.push(a[e+1]),i.push(a[e+2]),i.push(a[t+0]),i.push(a[t+1]),i.push(a[t+2]),i.push(a[r+0]),i.push(a[r+1]),i.push(a[r+2])},addUV:function(e,t,r){var a=this.uvs,i=this.object.geometry.uvs;i.push(a[e+0]),i.push(a[e+1]),i.push(a[t+0]),i.push(a[t+1]),i.push(a[r+0]),i.push(a[r+1])},addUVLine:function(e){var t=this.uvs,r=this.object.geometry.uvs;r.push(t[e+0]),r.push(t[e+1])},addFace:function(e,t,r,a,i,s,n,o,h,l,d,u){var p,c=this.vertices.length,m=this.parseVertexIndex(e,c),f=this.parseVertexIndex(t,c),v=this.parseVertexIndex(r,c);if(void 0===a?this.addVertex(m,f,v):(p=this.parseVertexIndex(a,c),this.addVertex(m,f,p),this.addVertex(f,v,p)),void 0!==i){var g=this.uvs.length;m=this.parseUVIndex(i,g),f=this.parseUVIndex(s,g),v=this.parseUVIndex(n,g),void 0===a?this.addUV(m,f,v):(p=this.parseUVIndex(o,g),this.addUV(m,f,p),this.addUV(f,v,p))}if(void 0!==h){var x=this.normals.length;m=this.parseNormalIndex(h,x),f=h===l?m:this.parseNormalIndex(l,x),v=h===d?m:this.parseNormalIndex(d,x),void 0===a?this.addNormal(m,f,v):(p=this.parseNormalIndex(u,x),this.addNormal(m,f,p),this.addNormal(f,v,p))}},addLineGeometry:function(e,t){this.object.geometry.type="Line";for(var r=this.vertices.length,a=this.uvs.length,i=0,s=e.length;i0?V.addAttribute("normal",new THREE.BufferAttribute(new Float32Array(j.normals),3)):V.computeVertexNormals(),j.uvs.length>0&&V.addAttribute("uv",new THREE.BufferAttribute(new Float32Array(j.uvs),2));for(var w=[],H=0,R=y.length;H1){for(var H=0,R=y.length;H0?t:"visual_scene0"]}return null}function n(){var e=Le.querySelectorAll("instance_kinematics_model")[0];if(e){var t=e.getAttribute("url").replace(/^#/,"");return Oe[t.length>0?t:"kinematics_model0"]}return null}function o(){He=[],h(Ve)}function h(e){var t=Ae.getChildById(e.colladaId,!0),i=null;if(t&&t.keys){i={fps:60,hierarchy:[{node:t,keys:t.keys,sids:t.sids}],node:e,name:"animation_"+e.name,length:0},He.push(i);for(var s=0,r=t.keys.length;s=0){var n=t.invBindMatrices[r];s.invBindMatrix=n,s.skinningMatrix=new THREE.Matrix4,s.skinningMatrix.multiplyMatrices(s.world,n),s.animatrix=new THREE.Matrix4,s.animatrix.copy(s.localworld),s.weights=[];for(var a=0;aa.limits.max||i1)for(C=new THREE.MultiMaterial(w),a=0;a0?(C.morphTargets=!0,C.skinning=!1):(C.morphTargets=!1,C.skinning=!0),A=new THREE.SkinnedMesh(H,C,(!1)),A.name="skin_"+qe.length,qe.push(A)):void 0!==s?(c(H,s),C.morphTargets=!0,A=new THREE.Mesh(H,C),A.name="morph_"+Ie.length,Ie.push(A)):A=H.isLineStrip===!0?new THREE.Line(H):new THREE.Mesh(H,C),n.add(A)}}for(r=0;rt)break}return i}function N(e,t){for(var i=-1,s=0,r=e.length;s=t&&(i=s)}return i}function k(e,t,i,s){var r=E(e,s,i?i-1:0),a=T(e,s,i+1);if(r&&a){var n,o=(t.time-r.time)/(a.time-r.time),h=r.getTarget(s),l=a.getTarget(s).data,c=h.data;if("matrix"===h.type)n=c;else if(c.length){n=[];for(var d=0;d=0?i:i+e.length;i>=0;i--){var s=e[i];if(s.hasTarget(t))return s}return null}function R(){this.id="",this.init_from=""}function _(){this.id="",this.name="",this.type="",this.skin=null,this.morph=null}function A(){this.method=null,this.source=null,this.targets=null,this.weights=null}function C(){this.source="",this.bindShapeMatrix=null,this.invBindMatrices=[],this.joints=[],this.weights=[]}function H(){this.id="",this.name="",this.nodes=[],this.scene=new THREE.Group}function M(){this.id="",this.name="",this.sid="",this.nodes=[],this.controllers=[],this.transforms=[],this.geometries=[],this.channels=[],this.matrix=new THREE.Matrix4}function j(){this.sid="",this.type="",this.data=[],this.obj=null}function O(){this.url="",this.skeleton=[],this.instance_material=[]}function S(){this.symbol="",this.target=""}function I(){this.url="",this.instance_material=[]}function q(){this.id="",this.mesh=null}function L(e){this.geometry=e.id,this.primitives=[],this.vertices=null,this.geometry3js=null}function V(){this.material="",this.count=0,this.inputs=[],this.vcount=null,this.p=[],this.geometry=new THREE.Geometry}function X(){V.call(this),this.vcount=[]}function Y(){V.call(this),this.vcount=1}function Z(){V.call(this),this.vcount=3}function z(){this.source="",this.count=0,this.stride=0,this.params=[]}function F(){this.input={}}function U(){this.semantic="",this.offset=0,this.source="",this.set=0}function B(e){this.id=e,this.type=null}function D(){this.id="",this.name="",this.instance_effect=null}function P(){this.color=new THREE.Color,this.color.setRGB(Math.random(),Math.random(),Math.random()),this.color.a=1,this.texture=null,this.texcoord=null,this.texOpts=null}function G(e,t){this.type=e,this.effect=t,this.material=null}function J(e){this.effect=e,this.init_from=null,this.format=null}function W(e){this.effect=e,this.source=null,this.wrap_s=null,this.wrap_t=null,this.minfilter=null,this.magfilter=null,this.mipfilter=null}function Q(){this.id="",this.name="",this.shader=null,this.surface={},this.sampler={}}function $(){this.url=""}function K(){this.id="",this.name="",this.source={},this.sampler=[],this.channel=[]}function ee(e){this.animation=e,this.source="",this.target="",this.fullSid=null,this.sid=null,this.dotSyntax=null,this.arrSyntax=null,this.arrIndices=null,this.member=null}function te(e){this.id="",this.animation=e,this.inputs=[],this.input=null,this.output=null,this.strideOut=null,this.interpolation=null,this.startTime=null,this.endTime=null,this.duration=0}function ie(e){this.targets=[],this.time=e}function se(){this.id="",this.name="",this.technique=""}function re(){this.url=""}function ae(){this.id="",this.name="",this.technique=""}function ne(){this.url=""}function oe(){this.id="",this.name="",this.joints=[],this.links=[]}function he(){this.sid="",this.name="",this.axis=new THREE.Vector3,this.limits={min:0,max:0},this.type="",this.static=!1,this.zeroPosition=0,this.middlePosition=0}function le(){this.sid="",this.name="",this.transforms=[],this.attachments=[]}function ce(){this.joint="",this.transforms=[],this.links=[]}function de(e){var t=e.getAttribute("id");return void 0!=Ye[t]?Ye[t]:(Ye[t]=new B(t).parse(e),Ye[t])}function pe(e){for(var t=me(e),i=[],s=0,r=t.length;s0?ge(e).split(/\s+/):[]}function ge(e){return e.replace(/^\s+/,"").replace(/\s+$/,"")}function ve(e,t,i){return e.hasAttribute(t)?parseInt(e.getAttribute(t),10):i}function ye(e,t){if("string"!=typeof e||""===e)return"";if(/^(https?:)?\/\//i.test(e))return e;if(/^data:.*,.*$/i.test(e))return e;var i=new URL((t||"")+e,location.href.substring(0,location.href.lastIndexOf("/")+1));return i.toString()}function be(e,t){var i=new THREE.ImageLoader;i.load(t,function(t){e.image=t,e.needsUpdate=!0})}function we(e,t){e.doubleSided=!1;var i=t.querySelectorAll("extra double_sided")[0];i&&i&&1===parseInt(i.textContent,10)&&(e.doubleSided=!0)}function xe(){if(We.convertUpAxis!==!0||$e===We.upAxis)Ke=null;else switch($e){case"X":Ke="Y"===We.upAxis?"XtoY":"XtoZ";break;case"Y":Ke="X"===We.upAxis?"YtoX":"YtoZ";break;case"Z":Ke="X"===We.upAxis?"ZtoX":"ZtoY"}}function Ne(e,t){if(We.convertUpAxis===!0&&$e!==We.upAxis)switch(Ke){case"XtoY":var i=e[0];e[0]=t*e[1],e[1]=i;break;case"XtoZ":var i=e[2];e[2]=e[1],e[1]=e[0],e[0]=i;break;case"YtoX":var i=e[0];e[0]=e[1],e[1]=t*i;break;case"YtoZ":var i=e[1];e[1]=t*e[2],e[2]=i;break;case"ZtoX":var i=e[0];e[0]=e[1],e[1]=e[2],e[2]=i;break;case"ZtoY":var i=e[1];e[1]=e[2],e[2]=t*i}}function ke(e,t){if(We.convertUpAxis!==!0||$e===We.upAxis)return t;switch(e){case"X":t="XtoY"===Ke?t*-1:t;break;case"Y":t="YtoZ"===Ke||"YtoX"===Ke?t*-1:t;break;case"Z":t="ZtoY"===Ke?t*-1:t}return t}function Te(e,t){var i=[e[t],e[t+1],e[t+2]];return Ne(i,-1),new THREE.Vector3(i[0],i[1],i[2])}function Ee(e){if(We.convertUpAxis){var t=[e[0],e[4],e[8]];Ne(t,-1),e[0]=t[0],e[4]=t[1],e[8]=t[2],t=[e[1],e[5],e[9]],Ne(t,-1),e[1]=t[0],e[5]=t[1],e[9]=t[2],t=[e[2],e[6],e[10]],Ne(t,-1),e[2]=t[0],e[6]=t[1],e[10]=t[2],t=[e[0],e[1],e[2]],Ne(t,-1),e[0]=t[0],e[1]=t[1],e[2]=t[2],t=[e[4],e[5],e[6]],Ne(t,-1),e[4]=t[0],e[5]=t[1],e[6]=t[2],t=[e[8],e[9],e[10]],Ne(t,-1),e[8]=t[0],e[9]=t[1],e[10]=t[2],t=[e[3],e[7],e[11]],Ne(t,-1),e[3]=t[0],e[7]=t[1],e[11]=t[2]}return(new THREE.Matrix4).set(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15])}function Re(e){if(e>-1&&e<3){var t=["X","Y","Z"],i={X:0,Y:1,Z:2};e=_e(t[e]),e=i[e]}return e}function _e(e){if(We.convertUpAxis)switch(e){case"X":switch(Ke){case"XtoY":case"XtoZ":case"YtoX":e="Y";break;case"ZtoX":e="Z"}break;case"Y":switch(Ke){case"XtoY":case"YtoX":case"ZtoX":e="X";break;case"XtoZ":case"YtoZ":case"ZtoY":e="Z"}break;case"Z":switch(Ke){case"XtoZ":e="X";break;case"YtoZ":case"ZtoX":case"ZtoY":e="Y"}}return e}var Ae,Ce,He,Me,je,Oe,Se,Ie,qe,Le=null,Ve=null,Xe=null,Ye={},Ze={},ze={},Fe={},Ue={},Be={},De={},Pe={},Ge={},Je=THREE.SmoothShading,We={centerGeometry:!1,convertUpAxis:!1,subdivideFaces:!0,upAxis:"Y",defaultEnvMap:null},Qe=1,$e="Y",Ke=null;return R.prototype.parse=function(e){this.id=e.getAttribute("id");for(var t=0;t=0,h=n.indexOf("(")>=0;if(o)a=n.split("."),n=a.shift(),s=a.shift();else if(h){i=n.split("("),n=i.shift();for(var l=0;l4&&We.subdivideFaces){var C=N.length?N:new THREE.Color;for(s=1;s4?[E[0],E[k+1],E[k+2]]:4===p?0===k?[E[0],E[1],E[3]]:[E[1].clone(),E[2],E[3].clone()]:[E[0],E[1],E[2]],void 0===t.faceVertexUvs[s]&&(t.faceVertexUvs[s]=[]),t.faceVertexUvs[s].push(R);else console.log("dropped face with vcount "+p+" for geometry with id: "+t.id);y+=u*p}},V.prototype.setVertices=function(e){for(var t=0;t0&&(this[i.nodeName]=parseFloat(r[0].textContent))}}return this.create(),this},G.prototype.create=function(){var e={},t=!1;if(void 0!==this.transparency&&void 0!==this.transparent){var i=(this.transparent,(this.transparent.color.r+this.transparent.color.g+this.transparent.color.b)/3*this.transparency);i>0&&(t=!0,e.transparent=!0,e.opacity=1-i)}var s={diffuse:"map",ambient:"lightMap",specular:"specularMap",emission:"emissionMap",bump:"bumpMap",normal:"normalMap"};for(var r in this)switch(r){case"ambient":case"emission":case"diffuse":case"specular":case"bump":case"normal":var a=this[r];if(a instanceof P)if(a.isTexture()){var n=a.texture,o=this.effect.sampler[n];if(void 0!==o&&void 0!==o.source){var h=this.effect.surface[o.source];if(void 0!==h){var l=Ze[h.init_from];if(l){var c,d=Se+l.init_from;if(altspace&&altspace.inClient)c=new THREE.Texture({src:ye(d)});else{var p=THREE.Loader.Handlers.get(d);null!==p?c=p.load(d):(c=new THREE.Texture,be(c,d))}"MIRROR"===o.wrap_s?c.wrapS=THREE.MirroredRepeatWrapping:"WRAP"===o.wrap_s||a.texOpts.wrapU?c.wrapS=THREE.RepeatWrapping:c.wrapS=THREE.ClampToEdgeWrapping,"MIRROR"===o.wrap_t?c.wrapT=THREE.MirroredRepeatWrapping:"WRAP"===o.wrap_t||a.texOpts.wrapV?c.wrapT=THREE.RepeatWrapping:c.wrapT=THREE.ClampToEdgeWrapping,c.offset.x=a.texOpts.offsetU,c.offset.y=a.texOpts.offsetV,c.repeat.x=a.texOpts.repeatU,c.repeat.y=a.texOpts.repeatV,e[s[r]]=c,"emission"===r&&(e.emissive=16777215)}}}}else"diffuse"!==r&&t||("emission"===r?e.emissive=a.color.getHex():e[r]=a.color.getHex());break;case"shininess":e[r]=this[r];break;case"reflectivity":e[r]=this[r],e[r]>0&&(e.envMap=We.defaultEnvMap),e.combine=THREE.MixOperation;break;case"index_of_refraction":e.refractionRatio=this[r],1!==this[r]&&(e.envMap=We.defaultEnvMap);break;case"transparency":}switch(e.shading=Je,e.side=this.effect.doubleSided?THREE.DoubleSide:THREE.FrontSide,void 0!==e.diffuse&&(e.color=e.diffuse,delete e.diffuse),this.type){case"constant":void 0!=e.emissive&&(e.color=e.emissive),this.material=new THREE.MeshBasicMaterial(e);break;case"phong":case"blinn":this.material=new THREE.MeshPhongMaterial(e);break;case"lambert":default:this.material=new THREE.MeshLambertMaterial(e)}return this.material},J.prototype.parse=function(e){for(var t=0;t=0,r=i.indexOf("(")>=0;if(s)t=i.split("."),this.sid=t.shift(),this.member=t.shift();else if(r){var a=i.split("(");this.sid=a.shift();for(var n=0;n1){s=[],t*=this.strideOut;for(var r=0;r1&&(o=1),l.length){r=[];for(var c=0;c=this.limits.max&&(this.static=!0),this.middlePosition=(this.limits.min+this.limits.max)/2,this},le.prototype.parse=function(e){this.sid=e.getAttribute("sid"),this.name=e.getAttribute("name"),this.transforms=[],this.attachments=[];for(var t=0;t=0&&(s[d.KHR_MATERIALS_COMMON]=new n(u)),console.time("GLTFLoader");var p=new E(u,s,{path:t||this.path,crossOrigin:this.crossOrigin});p.parse(function(e,t,n,a){console.log("------------ UltimateLoader ---------------"),console.timeEnd("GLTFLoader");var i={scene:e,scenes:t,cameras:n,animations:a};r(i)})}},e.Shaders={update:function(){console.warn("THREE.GLTFLoader.Shaders has been deprecated, and now updates automatically.")}},t.prototype.update=function(e,r){var t=this.boundUniforms;for(var n in t){var a=t[n];switch(a.semantic){case"MODELVIEW":var i=a.uniform.value;i.multiplyMatrices(r.matrixWorldInverse,a.sourceNode.matrixWorld);break;case"MODELVIEWINVERSETRANSPOSE":var s=a.uniform.value;this._m4.multiplyMatrices(r.matrixWorldInverse,a.sourceNode.matrixWorld),s.getNormalMatrix(this._m4);break;case"PROJECTION":var i=a.uniform.value;i.copy(r.projectionMatrix);break;case"JOINTMATRIX":for(var o=a.uniform.value,c=0;cE.length-1)return E=[],void(v=0);var e=E[v];v++,a(e[0],e[1],e[2])}function i(){0==v&&r()}function a(e,t,i){var a=s(n(e));switch(a.url=e,a.callback=t,null!=i&&(a.i=i),a.ext){case"obj":o(a);break;case"json":h(a);break;case"dae":c(a);break;case"gltf":d(a);break;case"glb":d(a);break;case"fbx":loadFBX(a);break;case"drc":loadDRACO(a);break;case"png":u(a);break;case"jpg":u(a);break;case"jpeg":u(a);break;case"bom":l(a);break;default:console.log("UltimateLoader: File extension -"+a.ext+"- not recognized! Object -"+a.name+"- did not load."),r()}}function s(e){var t=e.slice(0,e.lastIndexOf("/")+1),r=e.substr(e.lastIndexOf("/")+1),i=r.split("."),a=i[0],s=i[i.length-1].toLowerCase(),n={name:a,ext:s,baseUrl:t};return n}function n(e,t){if("string"!=typeof e||""===e)return"";if(/^(https?:)?\/\//i.test(e))return e;if(/^data:.*,.*$/i.test(e))return e;var r=new URL((t||"")+e,location.href.substring(0,location.href.lastIndexOf("/")+1));return r.toString()}function o(e){var t=e.name+".obj",r=e.name+".mtl",i=new THREE.MTLLoader;i.setPath(e.baseUrl),i.setTexturePath?i.setTexturePath(e.baseUrl):i.setBaseUrl(e.baseUrl),i.setCrossOrigin(g),i.load(r,function(r){r.preload();var i=new THREE.OBJLoader;i.setMaterials(r),i.setPath(e.baseUrl),i.load(t,function(t){e.object=t,m(e)},p,f)})}function l(e){var t=e.name+".bom",r=new THREE.BOMLoader;r.setTexturePath(e.baseUrl),r.setCrossOrigin(g),r.load(t,function(t){e.object=t,m(e)},p,f)}function h(e){var t=new THREE.ObjectLoader;t.load(e.url,function(t){e.object=t,m(e)},p,f)}function c(e){var t=new THREE.ColladaLoader;t.load(e.url,function(t){var r=t.scene;e.object=r,m(e)},p,f)}function u(t){var r=new THREE.TextureLoader;r.load(t.url,function(r){var i=r;if(e.loadImagesOnPlane){var a=r.image.naturalHeight/r.image.naturalWidth*e.imageSize,s=new THREE.PlaneGeometry(e.imageSize,a,e.imageSize),n=new THREE.MeshBasicMaterial({map:r,side:THREE.DoubleSide}),o=new THREE.Mesh(s,n);i=o}t.object=i,m(t)},p,f)}function d(e){var t=new THREE.GLTFLoader;t.load(e.url,function(t){var r=t.scene;e.object=r,m(e)},p,f)}function p(e){}function f(e){console.log("There was an error loading your object")}function m(t){null!=t.i?t.callback(t):t.callback(t.object),e.useQueue&&r(),console.log("UltimateLoader: Object "+t.name+" loaded!")}var E=[],v=0,g="anonymous";e.useQueue=!1,e.imageSize=32,e.loadImagesOnPlane=!1,e.load=function(r,s){e.useQueue?(t(r,s),i()):a(r,s)},e.multiload=function(r,s){console.time("Time");for(var n=[],o=0,l=function(e){n[e.i]=e.object,o++,o==r.length&&(s(n),console.timeEnd("Time"))},h=0;h=0?n.substring(0,o):n;l=l.toLowerCase();var h=o>=0?n.substring(o+1):"";if(h=h.trim(),"newmtl"===l)r={name:h},a[h]=r;else if(r)if("ka"===l||"kd"===l||"ks"===l){var c=h.split(i,3);r[l]=[parseFloat(c[0]),parseFloat(c[1]),parseFloat(c[2])]}else r[l]=h}}var u=new THREE.MTLLoader.MaterialCreator(this.texturePath||this.path,this.materialOptions);return u.setCrossOrigin(this.crossOrigin),u.setManager(this.manager),u.setMaterials(a),u}},THREE.MTLLoader.MaterialCreator=function(e,t){this.baseUrl=e||"",this.options=t,this.materialsInfo={},this.materials={},this.materialsArray=[],this.nameLookup={},this.side=this.options&&this.options.side?this.options.side:THREE.FrontSide,this.wrap=this.options&&this.options.wrap?this.options.wrap:THREE.RepeatWrapping},THREE.MTLLoader.MaterialCreator.prototype={constructor:THREE.MTLLoader.MaterialCreator,setCrossOrigin:function(e){this.crossOrigin=e},setManager:function(e){this.manager=e},setMaterials:function(e){this.materialsInfo=this.convert(e),this.materials={},this.materialsArray=[],this.nameLookup={}},convert:function(e){if(!this.options)return e;var t={};for(var r in e){var i=e[r],a={};t[r]=a;for(var s in i){var n=!0,o=i[s],l=s.toLowerCase();switch(l){case"kd":case"ka":case"ks":this.options&&this.options.normalizeRGB&&(o=[o[0]/255,o[1]/255,o[2]/255]),this.options&&this.options.ignoreZeroRGBs&&0===o[0]&&0===o[1]&&0===o[2]&&(n=!1)}n&&(a[l]=o)}}return t},preload:function(){for(var e in this.materialsInfo)this.create(e)},getIndex:function(e){return this.nameLookup[e]},getAsArray:function(){var e=0;for(var t in this.materialsInfo)this.materialsArray[e]=this.create(t),this.nameLookup[t]=e,e++;return this.materialsArray},create:function(e){return void 0===this.materials[e]&&this.createMaterial_(e),this.materials[e]},createMaterial_:function(e){function t(e,t){return"string"!=typeof t||""===t?"":/^https?:\/\//i.test(t)?t:e+t}function r(e,r){if(!s[e]){var a=i.getTextureParams(r,s),n=i.loadTexture(t(i.baseUrl,a.url));n.repeat.copy(a.scale),n.offset.copy(a.offset),n.wrapS=i.wrap,n.wrapT=i.wrap,s[e]=n}}var i=this,a=this.materialsInfo[e],s={name:e,side:this.side};for(var n in a){var o=a[n];if(""!==o)switch(n.toLowerCase()){case"kd":s.color=(new THREE.Color).fromArray(o);break;case"ks":s.specular=(new THREE.Color).fromArray(o);break;case"map_kd":r("map",o);break;case"map_ks":r("specularMap",o);break;case"map_bump":case"bump":r("bumpMap",o);break;case"ns":s.shininess=parseFloat(o);break;case"d":o<1&&(s.opacity=o,s.transparent=!0);break;case"Tr":o>0&&(s.opacity=1-o,s.transparent=!0)}}return this.materials[e]=new THREE.MeshPhongMaterial(s),this.materials[e]},getTextureParams:function(e,t){var r,i={scale:new THREE.Vector2(1,1),offset:new THREE.Vector2(0,0)},a=e.split(/\s+/);return r=a.indexOf("-bm"),r>=0&&(t.bumpScale=parseFloat(a[r+1]),a.splice(r,2)),r=a.indexOf("-s"),r>=0&&(i.scale.set(parseFloat(a[r+1]),parseFloat(a[r+2])),a.splice(r,4)),r=a.indexOf("-o"),r>=0&&(i.offset.set(parseFloat(a[r+1]),parseFloat(a[r+2])),a.splice(r,4)),i.url=a.join(" ").trim(),i},loadTexture:function(e,t,r,i,a){var s;if(altspace&&altspace.inClient)s=new THREE.Texture({src:e});else{var n=THREE.Loader.Handlers.get(e),o=void 0!==this.manager?this.manager:THREE.DefaultLoadingManager;null===n&&(n=new THREE.TextureLoader(o)),n.setCrossOrigin&&n.setCrossOrigin(this.crossOrigin),s=n.load(e,r,i,a)}return void 0!==t&&(s.mapping=t),s}},THREE.OBJLoader=function(e){this.manager=void 0!==e?e:THREE.DefaultLoadingManager,this.materials=null,this.regexp={vertex_pattern:/^v\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,normal_pattern:/^vn\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,uv_pattern:/^vt\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,face_vertex:/^f\s+(-?\d+)\s+(-?\d+)\s+(-?\d+)(?:\s+(-?\d+))?/,face_vertex_uv:/^f\s+(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)(?:\s+(-?\d+)\/(-?\d+))?/,face_vertex_uv_normal:/^f\s+(-?\d+)\/(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\/(-?\d+)(?:\s+(-?\d+)\/(-?\d+)\/(-?\d+))?/,face_vertex_normal:/^f\s+(-?\d+)\/\/(-?\d+)\s+(-?\d+)\/\/(-?\d+)\s+(-?\d+)\/\/(-?\d+)(?:\s+(-?\d+)\/\/(-?\d+))?/,object_pattern:/^[og]\s*(.+)?/,smoothing_pattern:/^s\s+(\d+|on|off)/,material_library_pattern:/^mtllib /,material_use_pattern:/^usemtl /}},THREE.OBJLoader.prototype={constructor:THREE.OBJLoader,load:function(e,t,r,i){var a=this,s=new THREE.FileLoader(a.manager);s.setPath(this.path),s.load(e,function(e){t(a.parse(e))},r,i)},setPath:function(e){this.path=e},setMaterials:function(e){this.materials=e},_createParserState:function(){var e={objects:[],object:{},vertices:[],normals:[],uvs:[],materialLibraries:[],startObject:function(e,t){if(this.object&&this.object.fromDeclaration===!1)return this.object.name=e,void(this.object.fromDeclaration=t!==!1);var r=this.object&&"function"==typeof this.object.currentMaterial?this.object.currentMaterial():void 0;if(this.object&&"function"==typeof this.object._finalize&&this.object._finalize(!0),this.object={name:e||"",fromDeclaration:t!==!1,geometry:{vertices:[],normals:[],uvs:[]},materials:[],smooth:!0,startMaterial:function(e,t){var r=this._finalize(!1);r&&(r.inherited||r.groupCount<=0)&&this.materials.splice(r.index,1);var i={index:this.materials.length,name:e||"",mtllib:Array.isArray(t)&&t.length>0?t[t.length-1]:"",smooth:void 0!==r?r.smooth:this.smooth,groupStart:void 0!==r?r.groupEnd:0,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(e){var t={index:"number"==typeof e?e:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return t.clone=this.clone.bind(t),t}};return this.materials.push(i),i},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(e){var t=this.currentMaterial();if(t&&t.groupEnd===-1&&(t.groupEnd=this.geometry.vertices.length/3,t.groupCount=t.groupEnd-t.groupStart,t.inherited=!1),e&&this.materials.length>1)for(var r=this.materials.length-1;r>=0;r--)this.materials[r].groupCount<=0&&this.materials.splice(r,1);return e&&0===this.materials.length&&this.materials.push({name:"",smooth:this.smooth}),t}},r&&r.name&&"function"==typeof r.clone){var i=r.clone(0);i.inherited=!0,this.object.materials.push(i)}this.objects.push(this.object)},finalize:function(){this.object&&"function"==typeof this.object._finalize&&this.object._finalize(!0)},parseVertexIndex:function(e,t){var r=parseInt(e,10);return 3*(r>=0?r-1:r+t/3)},parseNormalIndex:function(e,t){var r=parseInt(e,10);return 3*(r>=0?r-1:r+t/3)},parseUVIndex:function(e,t){var r=parseInt(e,10);return 2*(r>=0?r-1:r+t/2)},addVertex:function(e,t,r){var i=this.vertices,a=this.object.geometry.vertices;a.push(i[e+0]),a.push(i[e+1]),a.push(i[e+2]),a.push(i[t+0]),a.push(i[t+1]),a.push(i[t+2]),a.push(i[r+0]),a.push(i[r+1]),a.push(i[r+2])},addVertexLine:function(e){var t=this.vertices,r=this.object.geometry.vertices;r.push(t[e+0]),r.push(t[e+1]),r.push(t[e+2])},addNormal:function(e,t,r){var i=this.normals,a=this.object.geometry.normals;a.push(i[e+0]),a.push(i[e+1]),a.push(i[e+2]),a.push(i[t+0]),a.push(i[t+1]),a.push(i[t+2]),a.push(i[r+0]),a.push(i[r+1]),a.push(i[r+2])},addUV:function(e,t,r){var i=this.uvs,a=this.object.geometry.uvs;a.push(i[e+0]),a.push(i[e+1]),a.push(i[t+0]),a.push(i[t+1]),a.push(i[r+0]),a.push(i[r+1])},addUVLine:function(e){var t=this.uvs,r=this.object.geometry.uvs;r.push(t[e+0]),r.push(t[e+1])},addFace:function(e,t,r,i,a,s,n,o,l,h,c,u){var d,p=this.vertices.length,f=this.parseVertexIndex(e,p),m=this.parseVertexIndex(t,p),E=this.parseVertexIndex(r,p);if(void 0===i?this.addVertex(f,m,E):(d=this.parseVertexIndex(i,p),this.addVertex(f,m,d),this.addVertex(m,E,d)),void 0!==a){var v=this.uvs.length;f=this.parseUVIndex(a,v),m=this.parseUVIndex(s,v),E=this.parseUVIndex(n,v),void 0===i?this.addUV(f,m,E):(d=this.parseUVIndex(o,v),this.addUV(f,m,d),this.addUV(m,E,d))}if(void 0!==l){var g=this.normals.length;f=this.parseNormalIndex(l,g),m=l===h?f:this.parseNormalIndex(h,g),E=l===c?f:this.parseNormalIndex(c,g),void 0===i?this.addNormal(f,m,E):(d=this.parseNormalIndex(u,g),this.addNormal(f,m,d),this.addNormal(m,E,d))}},addLineGeometry:function(e,t){this.object.geometry.type="Line";for(var r=this.vertices.length,i=this.uvs.length,a=0,s=e.length;a0?A.addAttribute("normal",new THREE.BufferAttribute(new Float32Array(R.normals),3)):A.computeVertexNormals(),R.uvs.length>0&&A.addAttribute("uv",new THREE.BufferAttribute(new Float32Array(R.uvs),2));for(var N=[],M=0,H=w.length;M1){for(var M=0,H=w.length;M0?t:"visual_scene0"]}return null}function n(){var e=je.querySelectorAll("instance_kinematics_model")[0];if(e){var t=e.getAttribute("url").replace(/^#/,"");return Oe[t.length>0?t:"kinematics_model0"]}return null}function o(){_e=[],l(Pe)}function l(e){var t=He.getChildById(e.colladaId,!0),r=null;if(t&&t.keys){r={fps:60,hierarchy:[{node:t,keys:t.keys,sids:t.sids}],node:e,name:"animation_"+e.name,length:0},_e.push(r);for(var i=0,a=t.keys.length;i=0){var n=t.invBindMatrices[a];i.invBindMatrix=n,i.skinningMatrix=new THREE.Matrix4,i.skinningMatrix.multiplyMatrices(i.world,n),i.animatrix=new THREE.Matrix4,i.animatrix.copy(i.localworld),i.weights=[];for(var s=0;ss.limits.max||r1)for(L=new THREE.MultiMaterial(b),s=0;s<_.faces.length;s++){var S=_.faces[s];S.materialIndex=T[S.daeMaterial]}void 0!==r?(m(_,r),_.morphTargets.length>0?(L.morphTargets=!0,L.skinning=!1):(L.morphTargets=!1,L.skinning=!0),H=new THREE.SkinnedMesh(_,L,!1),H.name="skin_"+Fe.length,Fe.push(H)):void 0!==i?(c(_,i),L.morphTargets=!0,H=new THREE.Mesh(_,L),H.name="morph_"+Ie.length,Ie.push(H)):H=_.isLineStrip===!0?new THREE.Line(_):new THREE.Mesh(_,L),n.add(H)}}for(a=0;at)break}return r}function R(e,t){for(var r=-1,i=0,a=e.length;i=t&&(r=i)}return r}function w(e,t,r,i){var a=A(e,i,r?r-1:0),s=x(e,i,r+1);if(a&&s){var n,o=(t.time-a.time)/(s.time-a.time),l=a.getTarget(i),h=s.getTarget(i).data,c=l.data;if("matrix"===l.type)n=c;else if(c.length){n=[];for(var u=0;u=0?r:r+e.length;r>=0;r--){var i=e[r];if(i.hasTarget(t))return i}return null}function N(){this.id="",this.init_from=""}function M(){this.id="",this.name="",this.type="",this.skin=null,this.morph=null}function H(){this.method=null,this.source=null,this.targets=null,this.weights=null}function L(){this.source="",this.bindShapeMatrix=null,this.invBindMatrices=[],this.joints=[],this.weights=[]}function _(){this.id="",this.name="",this.nodes=[],this.scene=new THREE.Group}function S(){this.id="",this.name="",this.sid="",this.nodes=[],this.controllers=[],this.transforms=[],this.geometries=[],this.channels=[],this.matrix=new THREE.Matrix4}function k(){this.sid="",this.type="",this.data=[],this.obj=null}function O(){this.url="",this.skeleton=[],this.instance_material=[]}function C(){this.symbol="",this.target=""}function I(){this.url="",this.instance_material=[]}function F(){this.id="",this.mesh=null}function j(e){this.geometry=e.id,this.primitives=[],this.vertices=null,this.geometry3js=null}function P(){this.material="",this.count=0,this.inputs=[],this.vcount=null,this.p=[],this.geometry=new THREE.Geometry}function U(){P.call(this),this.vcount=[]}function B(){P.call(this),this.vcount=1}function D(){P.call(this),this.vcount=3}function V(){this.source="",this.count=0,this.stride=0,this.params=[]}function G(){this.input={}}function Y(){this.semantic="",this.offset=0,this.source="",this.set=0}function q(e){this.id=e,this.type=null}function X(){this.id="",this.name="",this.instance_effect=null}function z(){this.color=new THREE.Color,this.color.setRGB(Math.random(),Math.random(),Math.random()),this.color.a=1,this.texture=null,this.texcoord=null,this.texOpts=null}function W(e,t){this.type=e,this.effect=t,this.material=null}function Z(e){this.effect=e,this.init_from=null,this.format=null}function K(e){this.effect=e,this.source=null,this.wrap_s=null,this.wrap_t=null,this.minfilter=null,this.magfilter=null,this.mipfilter=null}function J(){this.id="",this.name="",this.shader=null,this.surface={},this.sampler={}}function Q(){this.url=""}function $(){this.id="",this.name="",this.source={},this.sampler=[],this.channel=[]}function ee(e){this.animation=e,this.source="",this.target="",this.fullSid=null,this.sid=null,this.dotSyntax=null,this.arrSyntax=null,this.arrIndices=null,this.member=null}function te(e){this.id="",this.animation=e,this.inputs=[],this.input=null,this.output=null,this.strideOut=null,this.interpolation=null,this.startTime=null,this.endTime=null,this.duration=0}function re(e){this.targets=[],this.time=e}function ie(){this.id="",this.name="",this.technique=""}function ae(){this.url=""}function se(){this.id="",this.name="",this.technique=""}function ne(){this.url=""; +}function oe(){this.id="",this.name="",this.joints=[],this.links=[]}function le(){this.sid="",this.name="",this.axis=new THREE.Vector3,this.limits={min:0,max:0},this.type="",this.static=!1,this.zeroPosition=0,this.middlePosition=0}function he(){this.sid="",this.name="",this.transforms=[],this.attachments=[]}function ce(){this.joint="",this.transforms=[],this.links=[]}function ue(e){var t=e.getAttribute("id");return void 0!=Be[t]?Be[t]:(Be[t]=new q(t).parse(e),Be[t])}function de(e){for(var t=me(e),r=[],i=0,a=t.length;i0?Ee(e).split(/\s+/):[]}function Ee(e){return e.replace(/^\s+/,"").replace(/\s+$/,"")}function ve(e,t,r){return e.hasAttribute(t)?parseInt(e.getAttribute(t),10):r}function ge(e,t){if("string"!=typeof e||""===e)return"";if(/^(https?:)?\/\//i.test(e))return e;if(/^data:.*,.*$/i.test(e))return e;var r=new URL((t||"")+e,location.href.substring(0,location.href.lastIndexOf("/")+1));return r.toString()}function Te(e,t){var r=new THREE.ImageLoader;r.load(t,function(t){e.image=t,e.needsUpdate=!0})}function be(e,t){e.doubleSided=!1;var r=t.querySelectorAll("extra double_sided")[0];r&&r&&1===parseInt(r.textContent,10)&&(e.doubleSided=!0)}function ye(){if(Ke.convertUpAxis!==!0||Qe===Ke.upAxis)$e=null;else switch(Qe){case"X":$e="Y"===Ke.upAxis?"XtoY":"XtoZ";break;case"Y":$e="X"===Ke.upAxis?"YtoX":"YtoZ";break;case"Z":$e="X"===Ke.upAxis?"ZtoX":"ZtoY"}}function Re(e,t){if(Ke.convertUpAxis===!0&&Qe!==Ke.upAxis)switch($e){case"XtoY":var r=e[0];e[0]=t*e[1],e[1]=r;break;case"XtoZ":var r=e[2];e[2]=e[1],e[1]=e[0],e[0]=r;break;case"YtoX":var r=e[0];e[0]=e[1],e[1]=t*r;break;case"YtoZ":var r=e[1];e[1]=t*e[2],e[2]=r;break;case"ZtoX":var r=e[0];e[0]=e[1],e[1]=e[2],e[2]=r;break;case"ZtoY":var r=e[1];e[1]=e[2],e[2]=t*r}}function we(e,t){if(Ke.convertUpAxis!==!0||Qe===Ke.upAxis)return t;switch(e){case"X":t="XtoY"===$e?t*-1:t;break;case"Y":t="YtoZ"===$e||"YtoX"===$e?t*-1:t;break;case"Z":t="ZtoY"===$e?t*-1:t}return t}function xe(e,t){var r=[e[t],e[t+1],e[t+2]];return Re(r,-1),new THREE.Vector3(r[0],r[1],r[2])}function Ae(e){if(Ke.convertUpAxis){var t=[e[0],e[4],e[8]];Re(t,-1),e[0]=t[0],e[4]=t[1],e[8]=t[2],t=[e[1],e[5],e[9]],Re(t,-1),e[1]=t[0],e[5]=t[1],e[9]=t[2],t=[e[2],e[6],e[10]],Re(t,-1),e[2]=t[0],e[6]=t[1],e[10]=t[2],t=[e[0],e[1],e[2]],Re(t,-1),e[0]=t[0],e[1]=t[1],e[2]=t[2],t=[e[4],e[5],e[6]],Re(t,-1),e[4]=t[0],e[5]=t[1],e[6]=t[2],t=[e[8],e[9],e[10]],Re(t,-1),e[8]=t[0],e[9]=t[1],e[10]=t[2],t=[e[3],e[7],e[11]],Re(t,-1),e[3]=t[0],e[7]=t[1],e[11]=t[2]}return(new THREE.Matrix4).set(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15])}function Ne(e){if(e>-1&&e<3){var t=["X","Y","Z"],r={X:0,Y:1,Z:2};e=Me(t[e]),e=r[e]}return e}function Me(e){if(Ke.convertUpAxis)switch(e){case"X":switch($e){case"XtoY":case"XtoZ":case"YtoX":e="Y";break;case"ZtoX":e="Z"}break;case"Y":switch($e){case"XtoY":case"YtoX":case"ZtoX":e="X";break;case"XtoZ":case"YtoZ":case"ZtoY":e="Z"}break;case"Z":switch($e){case"XtoZ":e="X";break;case"YtoZ":case"ZtoX":case"ZtoY":e="Y"}}return e}var He,Le,_e,Se,ke,Oe,Ce,Ie,Fe,je=null,Pe=null,Ue=null,Be={},De={},Ve={},Ge={},Ye={},qe={},Xe={},ze={},We={},Ze=THREE.SmoothShading,Ke={centerGeometry:!1,convertUpAxis:!1,subdivideFaces:!0,upAxis:"Y",defaultEnvMap:null},Je=1,Qe="Y",$e=null;return N.prototype.parse=function(e){this.id=e.getAttribute("id");for(var t=0;t=0,l=n.indexOf("(")>=0;if(o)s=n.split("."),n=s.shift(),i=s.shift();else if(l){r=n.split("("),n=r.shift();for(var h=0;h4&&Ke.subdivideFaces){var L=R.length?R:new THREE.Color;for(i=1;i4?[A[0],A[w+1],A[w+2]]:4===d?0===w?[A[0],A[1],A[3]]:[A[1].clone(),A[2],A[3].clone()]:[A[0],A[1],A[2]],void 0===t.faceVertexUvs[i]&&(t.faceVertexUvs[i]=[]),t.faceVertexUvs[i].push(N);else console.log("dropped face with vcount "+d+" for geometry with id: "+t.id);g+=p*d}},P.prototype.setVertices=function(e){for(var t=0;t0&&(this[r.nodeName]=parseFloat(a[0].textContent))}}return this.create(),this},W.prototype.create=function(){var e={},t=!1;if(void 0!==this.transparency&&void 0!==this.transparent){var r=(this.transparent,(this.transparent.color.r+this.transparent.color.g+this.transparent.color.b)/3*this.transparency);r>0&&(t=!0,e.transparent=!0,e.opacity=1-r)}var i={diffuse:"map",ambient:"lightMap",specular:"specularMap",emission:"emissionMap",bump:"bumpMap",normal:"normalMap"};for(var a in this)switch(a){case"ambient":case"emission":case"diffuse":case"specular":case"bump":case"normal":var s=this[a];if(s instanceof z)if(s.isTexture()){var n=s.texture,o=this.effect.sampler[n];if(void 0!==o&&void 0!==o.source){var l=this.effect.surface[o.source];if(void 0!==l){var h=De[l.init_from];if(h){var c,u=Ce+h.init_from;if(altspace&&altspace.inClient)c=new THREE.Texture({src:ge(u)});else{var d=THREE.Loader.Handlers.get(u);null!==d?c=d.load(u):(c=new THREE.Texture,Te(c,u))}"MIRROR"===o.wrap_s?c.wrapS=THREE.MirroredRepeatWrapping:"WRAP"===o.wrap_s||s.texOpts.wrapU?c.wrapS=THREE.RepeatWrapping:c.wrapS=THREE.ClampToEdgeWrapping,"MIRROR"===o.wrap_t?c.wrapT=THREE.MirroredRepeatWrapping:"WRAP"===o.wrap_t||s.texOpts.wrapV?c.wrapT=THREE.RepeatWrapping:c.wrapT=THREE.ClampToEdgeWrapping,c.offset.x=s.texOpts.offsetU,c.offset.y=s.texOpts.offsetV,c.repeat.x=s.texOpts.repeatU,c.repeat.y=s.texOpts.repeatV,e[i[a]]=c,"emission"===a&&(e.emissive=16777215)}}}}else"diffuse"!==a&&t||("emission"===a?e.emissive=s.color.getHex():e[a]=s.color.getHex());break;case"shininess":e[a]=this[a];break;case"reflectivity":e[a]=this[a],e[a]>0&&(e.envMap=Ke.defaultEnvMap),e.combine=THREE.MixOperation;break;case"index_of_refraction":e.refractionRatio=this[a],1!==this[a]&&(e.envMap=Ke.defaultEnvMap);break;case"transparency":}switch(e.shading=Ze,e.side=this.effect.doubleSided?THREE.DoubleSide:THREE.FrontSide,void 0!==e.diffuse&&(e.color=e.diffuse,delete e.diffuse),this.type){case"constant":void 0!=e.emissive&&(e.color=e.emissive),this.material=new THREE.MeshBasicMaterial(e);break;case"phong":case"blinn":this.material=new THREE.MeshPhongMaterial(e);break;case"lambert":default:this.material=new THREE.MeshLambertMaterial(e)}return this.material},Z.prototype.parse=function(e){for(var t=0;t=0,a=r.indexOf("(")>=0;if(i)t=r.split("."),this.sid=t.shift(),this.member=t.shift();else if(a){var s=r.split("(");this.sid=s.shift();for(var n=0;n1){i=[],t*=this.strideOut;for(var a=0;a1&&(o=1),h.length){a=[];for(var c=0;c=this.limits.max&&(this.static=!0), +this.middlePosition=(this.limits.min+this.limits.max)/2,this},he.prototype.parse=function(e){this.sid=e.getAttribute("sid"),this.name=e.getAttribute("name"),this.transforms=[],this.attachments=[];for(var t=0;t=0&&(n[u.KHR_MATERIALS_COMMON]=new i(h)),console.time("GLTFLoader");var d=new c(h,n,{path:r||this.path,crossOrigin:this.crossOrigin});d.parse(function(e,r,i,a){console.log("------------ UltimateLoader ---------------"),console.timeEnd("GLTFLoader");var s={scene:e,scenes:r,cameras:i,animations:a};t(s)})}},e.Shaders={update:function(){console.warn("THREE.GLTFLoader.Shaders has been deprecated, and now updates automatically.")}},r.prototype.update=function(e,t){var r=this.boundUniforms;for(var i in r){var a=r[i];switch(a.semantic){case"MODELVIEW":var s=a.uniform.value;s.multiplyMatrices(t.matrixWorldInverse,a.sourceNode.matrixWorld);break;case"MODELVIEWINVERSETRANSPOSE":var n=a.uniform.value;this._m4.multiplyMatrices(t.matrixWorldInverse,a.sourceNode.matrixWorld),n.getNormalMatrix(this._m4);break;case"PROJECTION":var s=a.uniform.value;s.copy(t.projectionMatrix);break;case"JOINTMATRIX":for(var o=a.uniform.value,l=0;l0?new Uint8Array(g.buffer,T,e):new Uint8Array);return T+=Uint8Array.BYTES_PER_ELEMENT*e,t}function n(e){if(T%Uint16Array.BYTES_PER_ELEMENT===0){var t=new Uint16Array(g.buffer,T,e);return T+=Uint16Array.BYTES_PER_ELEMENT*e,t}for(var t=new Uint16Array(e),r=0;r0?THREE.SmoothShading:THREE.FlatShading,this.debug&&console.log("Group Material",$,C)}var ee=new THREE.Mesh(Q,C);W&&(ee.name=W),P.add(ee)}}}}return this.performanceTimer&&console.timeEnd("BOMLoader"),y}},THREE.BOMLoaderUtil=THREE.BOMLoaderUtil||{},THREE.BOMLoaderUtil.multiload=function(e,t){function r(e,r){var s=new THREE.BOMLoader;s.setTexturePath(r.url.split("/").slice(0,-1).join("/")+"/"),void 0!==r.debug&&s.setDebug(r.debug),void 0!==r.timer&&s.setPerfTimer(r.timer),void 0!==r.crossOrigin&&s.setCrossOrigin(r.crossOrigin),void 0!==r.responseType&&s.setResponseType(r.responseType),s.load(r.url,function(s){r.object=s,a[e]=r,--i<=0&&t(a)})}e=e.constructor===Array?e:[e];for(var i=e.length,a=[],s=0;s 0 ) ? new Uint8Array( view.buffer, pos, length ) : new Uint8Array() ); + pos += Uint8Array.BYTES_PER_ELEMENT * length; + return value; + + } + + function readUint16Array ( length ) { + + if ( ( pos % Uint16Array.BYTES_PER_ELEMENT ) === 0 ) { + + // Aligned Access + var value = new Uint16Array( view.buffer, pos, length ); + pos += Uint16Array.BYTES_PER_ELEMENT * length; + return value; + + } + + // Unaligned Access + var value = new Uint16Array( length ); + for ( var i = 0; i < length; ++i, pos += Uint16Array.BYTES_PER_ELEMENT ) value[ i ] = view.getUint16( pos, true ); + return value; + + } + + function readFloat32Array ( length ) { + + if ( ( pos % Float32Array.BYTES_PER_ELEMENT ) === 0 ) { + + // Aligned Access + var value = new Float32Array( view.buffer, pos, length ); + pos += Float32Array.BYTES_PER_ELEMENT * length; + return value; + + } + + // Unaligned Access + var value = new Float32Array( length ); + for ( var i = 0; i < length; ++i, pos += Float32Array.BYTES_PER_ELEMENT ) value[ i ] = view.getFloat32( pos, true ); + return value; + + } + + var scope = this; + + function resolveURL ( url ) { + + if ( typeof url !== 'string' || url === '' ) return ''; + + // Absolute URL + if ( /^https?:\/\//i.test( url ) ) return url; + + var absoluteUrl = new URL(( scope.texturePath || scope.path || '' ) + url, location.href.substring( 0, location.href.lastIndexOf( '/' ) + 1 )); + return absoluteUrl.toString(); + + } + + function loadTexture ( url ) { + + url = resolveURL( url ); + var texture; + + if ( altspace && altspace.inClient ) { + + // Defer Texture Image Loading To Native Altspace Client + texture = new THREE.Texture( { src: url } ); + + } else { + + var loader = THREE.Loader.Handlers.get( url ); + if ( loader === null ) loader = new THREE.TextureLoader( scope.manager ); + loader.setCrossOrigin( scope.crossOrigin ); + texture = loader.load( url ); + + } + + texture.side = THREE.FrontSide; + texture.wrapS = texture.wrapT = THREE.RepeatWrapping; + + return texture; + + } + + // File Signature + var fileSignature = readString( 3 ); + if ( this.debug ) console.log( 'File Signature', fileSignature ); + + // Version + var version = readUint8(); + if ( this.debug ) console.log( 'Version', version ); + + // File Data Attributes + var fileAttributes = readUint16(); + if ( this.debug ) { + + console.log( + + 'FileAttributes:', '\n', + 'Material Library', ( objectAttributes & FileDataAttribute.MATERIAL_LIBRARY ) ? true : false + + ); + + } + + // Materials + var materials = []; + if ( fileAttributes & FileDataAttribute.MATERIAL_LIBRARY ) { + + // Material Count + var materialCount = readUint16(); + if ( this.debug ) console.log( 'Material Count', materialCount ); + + for ( var i = 0; i < materialCount; ++i ) { + + // Material Data Attributes + var materialAttributes = readUint32(); + if ( this.debug ) { + + console.log( + + 'MaterialAttributes:', '\n', + 'Illumination Model', ( materialAttributes & MaterialDataAttribute.ILLUMINATION_MODEL ) ? true : false, '\n', + 'Specular Exponent', ( materialAttributes & MaterialDataAttribute.SPECULAR_EXPONENT ) ? true : false, '\n', + 'Optical Density', ( materialAttributes & MaterialDataAttribute.OPTICAL_DENSITY ) ? true : false, '\n', + 'Dissolve', ( materialAttributes & MaterialDataAttribute.DISSOLVE ) ? true : false, '\n', + 'Transmission Filter', ( materialAttributes & MaterialDataAttribute.TRANSMISSION_FILTER ) ? true : false, '\n', + 'Ambient Reflectance', ( materialAttributes & MaterialDataAttribute.AMBIENT_REFLECTANCE ) ? true : false, '\n', + 'Diffuse Reflectance', ( materialAttributes & MaterialDataAttribute.DIFFUSE_REFLECTANCE ) ? true : false, '\n', + 'Specular Reflectance', ( materialAttributes & MaterialDataAttribute.SPECULAR_REFLECTANCE ) ? true : false, '\n', + 'Ambient Map', ( materialAttributes & MaterialDataAttribute.AMBIENT_MAP ) ? true : false, '\n', + 'Diffuse Map', ( materialAttributes & MaterialDataAttribute.DIFFUSE_MAP ) ? true : false, '\n', + 'Specular Map', ( materialAttributes & MaterialDataAttribute.SPECULAR_MAP ) ? true : false, '\n', + 'Dissolve Map', ( materialAttributes & MaterialDataAttribute.DISSOLVE_MAP ) ? true : false, '\n', + 'Bump Map', ( materialAttributes & MaterialDataAttribute.BUMP_MAP ) ? true : false, '\n', + 'Displacement Map', ( materialAttributes & MaterialDataAttribute.DISPLACEMENT_MAP ) ? true : false, '\n', + 'Face Culling', ( materialAttributes & MaterialDataAttribute.FACE_CULLING ) ? true : false, '\n', + 'Light Map', ( materialAttributes & MaterialDataAttribute.LIGHT_MAP ) ? true : false + + ); + + } + + var params = {}; + + // Material Name + params.name = readString( readUint16() ); + if ( this.debug ) console.log( 'Material Name', params.name ); + + // Illumination Model (illum) + if ( materialAttributes & MaterialDataAttribute.ILLUMINATION_MODEL ) { + + readUint8(); + // Not supported + + } + + // Specular Exponent (Ns) + if ( materialAttributes & MaterialDataAttribute.SPECULAR_EXPONENT ) { + + params.shininess = readFloat32(); + if ( this.debug ) console.log( 'Specular Exponent', params.shininess ); + + } + + // Optical Density (Ni) + if ( materialAttributes & MaterialDataAttribute.OPTICAL_DENSITY ) { + + readFloat32(); + // Not supported + + } + + // Dissolve (d / [1 - Tr]) + if ( materialAttributes & MaterialDataAttribute.DISSOLVE ) { + + params.opacity = readFloat32(); + params.transparent = true; + if ( this.debug ) console.log( 'Dissolve', params.opacity ); + + } + + // Transmission Filter (Tf) + if ( materialAttributes & MaterialDataAttribute.TRANSMISSION_FILTER ) { + + readFloat32(), readFloat32(), readFloat32(); + // Not supported + + } + + // Ambient Reflectance (Ka) + if ( materialAttributes & MaterialDataAttribute.AMBIENT_REFLECTANCE ) { + + readFloat32(), readFloat32(), readFloat32(); + // Assumes ambient and diffuse are linked + + } + + // Diffuse Reflectance (Kd) + if ( materialAttributes & MaterialDataAttribute.DIFFUSE_REFLECTANCE ) { + + params.color = new THREE.Color( readFloat32(), readFloat32(), readFloat32() ); + if ( this.debug ) console.log( 'Diffuse Reflectance', params.color ); + + } + + // Specular Reflectance (Ks) + if ( materialAttributes & MaterialDataAttribute.SPECULAR_REFLECTANCE ) { + + params.specular = new THREE.Color( readFloat32(), readFloat32(), readFloat32() ); + if ( this.debug ) console.log( 'Specular Reflectance', params.specular ); + + } + + // Emissive Reflectance (Ke) + if ( materialAttributes & MaterialDataAttribute.EMISSIVE_REFLECTANCE ) { + + params.emissive = new THREE.Color( readFloat32(), readFloat32(), readFloat32() ); + if ( this.debug ) console.log( 'Emissive Reflectance', params.emissive ); + + } + + // Ambient Map (map_Ka) + if ( materialAttributes & MaterialDataAttribute.AMBIENT_MAP ) { + + var mapDataAttributes = readUint16(); + if ( mapDataAttributes & MapDataAttribute.PATH ) readString( readUint16() ); + if ( mapDataAttributes & MapDataAttribute.SCALE ) readFloat32(), readFloat32(); + if ( mapDataAttributes & MapDataAttribute.OFFSET ) readFloat32(), readFloat32(); + // Assumes ambient and diffuse are linked + + } + + // Diffuse Map (map_Kd) + if ( materialAttributes & MaterialDataAttribute.DIFFUSE_MAP ) { + + var mapDataAttributes = readUint16(); + var map = loadTexture( ( mapDataAttributes & MapDataAttribute.PATH ) ? readString( readUint16() ) : '' ); + if ( mapDataAttributes & MapDataAttribute.SCALE ) map.repeat.set( readFloat32(), readFloat32() ); + if ( mapDataAttributes & MapDataAttribute.OFFSET ) map.offset.set( readFloat32(), readFloat32() ); + params.map = map; + if ( this.debug && ( mapDataAttributes & MapDataAttribute.PATH ) ) console.log( 'Diffuse Map', map ); + + } + + // Specular Map (map_Ks) + if ( materialAttributes & MaterialDataAttribute.SPECULAR_MAP ) { + + var mapDataAttributes = readUint16(); + var map = loadTexture( ( mapDataAttributes & MapDataAttribute.PATH ) ? readString( readUint16() ) : '' ); + if ( mapDataAttributes & MapDataAttribute.SCALE ) map.repeat.set( readFloat32(), readFloat32() ); + if ( mapDataAttributes & MapDataAttribute.OFFSET ) map.offset.set( readFloat32(), readFloat32() ); + params.specularMap = map; + + } + + // Emissive Map (map_Ke) + if ( materialAttributes & MaterialDataAttribute.EMISSIVE_MAP ) { + + var mapDataAttributes = readUint16(); + var map = loadTexture( ( mapDataAttributes & MapDataAttribute.PATH ) ? readString( readUint16() ) : '' ); + if ( mapDataAttributes & MapDataAttribute.SCALE ) map.repeat.set( readFloat32(), readFloat32() ); + if ( mapDataAttributes & MapDataAttribute.OFFSET ) map.offset.set( readFloat32(), readFloat32() ); + params.emissiveMap = map; + + } + + // Dissolve Map (map_d) + if ( materialAttributes & MaterialDataAttribute.DISSOLVE_MAP ) { + + var mapDataAttributes = readUint16(); + var map = loadTexture( ( mapDataAttributes & MapDataAttribute.PATH ) ? readString( readUint16() ) : '' ); + if ( mapDataAttributes & MapDataAttribute.SCALE ) map.repeat.set( readFloat32(), readFloat32() ); + if ( mapDataAttributes & MapDataAttribute.OFFSET ) map.offset.set( readFloat32(), readFloat32() ); + params.alphaMap = map; + params.transparent = true; + + } + + // Bump Map (map_bump / bump) + if ( materialAttributes & MaterialDataAttribute.BUMP_MAP ) { + + var mapDataAttributes = readUint16(); + var map = loadTexture( ( mapDataAttributes & MapDataAttribute.PATH ) ? readString( readUint16() ) : '' ); + if ( mapDataAttributes & MapDataAttribute.SCALE ) map.repeat.set( readFloat32(), readFloat32() ); + if ( mapDataAttributes & MapDataAttribute.OFFSET ) map.offset.set( readFloat32(), readFloat32() ); + if ( mapDataAttributes & MapDataAttribute.BUMP_SCALE ) params.bumpScale = readFloat32(); + params.bumpMap = map; + + } + + // Displacement Map (map_disp / disp) + if ( materialAttributes & MaterialDataAttribute.DISPLACEMENT_MAP ) { + + var mapDataAttributes = readUint16(); + var map = loadTexture( ( mapDataAttributes & MapDataAttribute.PATH ) ? readString( readUint16() ) : '' ); + if ( mapDataAttributes & MapDataAttribute.SCALE ) map.repeat.set( readFloat32(), readFloat32() ); + if ( mapDataAttributes & MapDataAttribute.OFFSET ) map.offset.set( readFloat32(), readFloat32() ); + if ( mapDataAttributes & MapDataAttribute.DISPLACEMENT_SCALE ) params.displacementScale = readFloat32(); + params.displacementMap = map; + + } + + // Face Culling (cull_face) + if ( materialAttributes & MaterialDataAttribute.FACE_CULLING ) { + + var faceCulling = readUint8(); + if ( faceCulling === FaceCulling.ALL ) params.visible = false; + else if ( faceCulling === FaceCulling.FRONT ) params.side = THREE.BackSide; + else if ( faceCulling === FaceCulling.BACK ) params.side = THREE.FrontSide; + else params.side = THREE.DoubleSide; + + } + + // Light Map (lightmap) + if ( materialAttributes & MaterialDataAttribute.LIGHT_MAP ) { + + var mapDataAttributes = readUint16(); + var map = loadTexture( ( mapDataAttributes & MapDataAttribute.PATH ) ? readString( readUint16() ) : '' ); + if ( mapDataAttributes & MapDataAttribute.SCALE ) map.repeat.set( readFloat32(), readFloat32() ); + if ( mapDataAttributes & MapDataAttribute.OFFSET ) map.offset.set( readFloat32(), readFloat32() ); + if ( mapDataAttributes & MapDataAttribute.LIGHTMAP_INTENSITY ) params.lightMapIntensity = readFloat32(); + params.lightMap = map; + + } + + var material = new THREE.MeshPhongMaterial( params ); + materials.push( material ); + + } + + } + + // Asset Count + var assetCount = readUint16(); + if ( this.debug ) console.log( 'Asset Count', assetCount ); + + for ( var a = 0; a < assetCount; ++a ) { + + // Asset Data Attributes + var assetAttributes = readUint16(); + + if ( this.debug ) { + + console.log( + + 'AssetAttributes:', '\n', + 'Name', ( assetAttributes & AssetDataAttribute.NAME ) ? true : false + + ); + + } + + var asset = assets; + if ( isAssetArray ) { + + asset = new THREE.Group(); + assets.push( asset ); + + } + + // Asset Name + if ( assetAttributes & AssetDataAttribute.NAME ) { + + var assetName = readString( readUint16() ); + if ( this.debug ) console.log( 'Asset Name', assetName ); + if ( !isAssetArray ) asset.name = assetName; + + } + + // Object Count + var objectCount = readUint16(); + if ( this.debug ) console.log( 'Object Count', objectCount ); + + for ( var i = 0; i < objectCount; ++i ) { + + // Object Data Attributes + var objectAttributes = readUint16(); + + if ( this.debug ) { + + console.log( + + 'ObjectAttributes:', '\n', + 'Geometry', ( objectAttributes & ObjectDataAttribute.GEOMETRY ) ? true : false + + ); + + } + + var vertices = {}; + if ( objectAttributes & ObjectDataAttribute.GEOMETRY ) { + + // Geometry Data Attributes + var geometryAttributes = readUint16(); + if ( this.debug ) { + + console.log( + + 'GeometryAttributes:', '\n', + 'Normal', ( geometryAttributes & GeometryDataAttribute.NORMAL ) ? true : false, '\n', + 'UV1', ( geometryAttributes & GeometryDataAttribute.UV1 ) ? true : false, '\n', + 'UV2', ( geometryAttributes & GeometryDataAttribute.UV2 ) ? true : false + + ); + + } + + // Vertex Count + var vertexCount = readUint32(); + if ( this.debug ) console.log( 'Vertex Count', vertexCount ); + + // Vertex Positions + vertices.positions = readFloat32Array( vertexCount * 3 ); + + // Vertex Normals + if ( geometryAttributes & GeometryDataAttribute.NORMAL ) vertices.normals = readFloat32Array( vertexCount * 3 ); + + // Vertex UVs + if ( geometryAttributes & GeometryDataAttribute.UV1 ) vertices.uvs = readFloat32Array( vertexCount * 2 ); + if ( geometryAttributes & GeometryDataAttribute.UV2 ) vertices.uvs2 = readFloat32Array( vertexCount * 2 ); + + } + + // Group Count + var groupCount = readUint16(); + if ( this.debug ) console.log( 'Group Count', groupCount ); + + for ( var j = 0; j < groupCount; ++j ) { + + // Group Data Attributes + var groupAttributes = readUint16(); + if ( this.debug ) { + + console.log( + + 'GroupAttributes:', '\n', + 'Index', ( groupAttributes & GroupDataAttribute.INDEX ) ? true : false, '\n', + 'Smoothing', ( groupAttributes & GroupDataAttribute.SMOOTHING ) ? true : false, '\n', + 'Material', ( groupAttributes & GroupDataAttribute.MATERIAL ) ? true : false + + ); + + } + + // Group Name + var groupName; + if ( groupAttributes & GroupDataAttribute.NAME ) { + + groupName = readString( readUint16() ); + if ( this.debug ) console.log( 'Group Name', groupName ); + + } + + if ( objectAttributes & ObjectDataAttribute.GEOMETRY ) { + + // Indices + var indices; + if ( groupAttributes & GroupDataAttribute.INDEX ) { + + // Index Count + var indexCount = readUint32(); + if ( this.debug ) console.log( 'Index Count', indexCount ); + + // Indices + indices = readUint16Array( indexCount ); + + } + + // Smoothing + var smoothing = ( groupAttributes & GroupDataAttribute.SMOOTHING ) ? readUint8() : 0; + if ( this.debug && ( groupAttributes & GroupDataAttribute.SMOOTHING ) ) console.log( 'Smoothing', smoothing ); + + var geometry = new THREE.BufferGeometry(); + if ( vertices.positions ) geometry.addAttribute( 'position', new THREE.BufferAttribute( vertices.positions, 3 ) ); + vertices.normals ? geometry.addAttribute( 'normal', new THREE.BufferAttribute( vertices.normals, 3 ) ) : geometry.computeVertexNormals(); + if ( vertices.uvs ) geometry.addAttribute( 'uv', new THREE.BufferAttribute( vertices.uvs, 2 ) ); + if ( vertices.uvs2 ) geometry.addAttribute( 'uv2', new THREE.BufferAttribute( vertices.uvs2, 2 ) ); + if ( indices ) geometry.setIndex( new THREE.BufferAttribute( indices, 1 ) ); + geometry.addGroup( 0, 1, 0 ); + + var material; + if ( groupAttributes & GroupDataAttribute.MATERIAL ) { + + // Material ID + var materialId = readUint16(); + material = materials[ materialId ].clone() || new THREE.MeshPhongMaterial(); + material.shading = ( smoothing > 0 ) ? THREE.SmoothShading : THREE.FlatShading; + if ( this.debug ) console.log( 'Group Material', materialId, material ); + + } + + var mesh = new THREE.Mesh( geometry, material ); + if ( groupName ) mesh.name = groupName; + asset.add( mesh ); + + } + + } + + } + + } + + if ( this.performanceTimer ) console.timeEnd( 'BOMLoader' ); + + return assets; + + } + +}; + +THREE.BOMLoaderUtil = THREE.BOMLoaderUtil || {}; +THREE.BOMLoaderUtil.multiload = function ( requests, onComplete ) { + + requests = ( requests.constructor === Array ) ? requests : [ requests ]; + var requestCount = requests.length; + var responses = []; + + function loadRequest ( index, request ) { + + var loader = new THREE.BOMLoader(); + loader.setTexturePath( request.url.split( '/' ).slice( 0, -1 ).join( '/' ) + '/' ); + if ( request.debug !== undefined ) loader.setDebug( request.debug ); + if ( request.timer !== undefined ) loader.setPerfTimer( request.timer ); + if ( request.crossOrigin !== undefined ) loader.setCrossOrigin( request.crossOrigin ); + if ( request.responseType !== undefined ) loader.setResponseType( request.responseType ); + loader.load( request.url, function ( object ) { + + request.object = object; + responses[ index ] = request; + if ( --requestCount <= 0 ) onComplete( responses ); + + } ); + + } + + for ( var i = 0; i < requests.length; ++i ) loadRequest( i, requests[ i ] ); + +}; diff --git a/dist/UltimateLoader2.min.js b/dist/UltimateLoader2.min.js index a5c7c7f..cb34884 100644 --- a/dist/UltimateLoader2.min.js +++ b/dist/UltimateLoader2.min.js @@ -1,6 +1,3 @@ -var UltimateLoader=UltimateLoader||{};!function(e){"use strict";function t(e){var t=r(e);if(t){var o={};return o.urlInfo=n(t),o.shouldUpdate=!1,"mtl"===o.urlInfo.ext?void(I=o.urlInfo):o}}function o(e){var t=[];return a(e,function(o,a){var l=r(a.url);if(l){var i={};if(i.urlInfo=n(l),i.object=a,i.shouldUpdate=!0,i.name=o,i.parent=e,a.mtl){var s=r(a.mtl);s&&(i.mtl=n(s))}t.push(i)}}),t}function a(e,t){for(var o in e)t.apply(this,[o,e[o]]),null!==e[o]&&"object"==typeof e[o]&&a(e[o],t)}function n(e){var t=e.slice(0,e.lastIndexOf("/")+1);if(""===t||null===t||"undefined"===t)return void console.error("UltimateLoader: "+name+" failed to load as it must pass a valid url");var o=e.substr(e.lastIndexOf("/")+1),a=o.split("."),n=a[0],r=a[a.length-1].toLowerCase(),l={name:n,ext:r,baseUrl:t,url:e};return l}function r(e){if("string"!=typeof e||""===e)return!1;if(/^https?:\/\//i.test(e))return e;var t=new URL(e,location.href.substring(0,location.href.lastIndexOf("/")+1));return t.toString()}function l(e,t,o){switch(e){case 0:o.x=t;break;case 1:o.y=t;break;case 2:o.z=t;break;case 3:o.w=t;break;default:throw new Error("index is out of range: "+e)}}function i(){this.count=0,this.complete=!1,this.size=0,this.loadedObjects=[]}function s(e){if(R[e.urlInfo.url]){var t=R[e.urlInfo.url];t.model.object3d?c(e,t):t.toClone.push(e),e.fetchFromCache=!0}else R[e.urlInfo.url]={toClone:[],model:e},e.isCache=!0}function c(e,t){e.object3d=t.model.object3d.clone(),e.object3d.position.set(0,0,0),e.object3d.rotation.set(0,0,0),e.object3d.quaternion.set(0,0,0,1),e.object3d.scale.set(1,1,1),e.object3d.traverse(function(e){e instanceof THREE.Mesh&&(e.material=e.material.clone())}),e.callback()}function u(t,o){if(t.isCache)for(var a=R[t.urlInfo.url].toClone,n=0;n=0?o.substring(0,n):o;p=p.toLowerCase();var h=n>=0?o.substring(n+1):"";if(h=h.trim(),"newmtl"===p)e={name:h},s[h]=e;else if(e)if("ka"===p||"kd"===p||"ks"===p){var l=h.split(r,3);e[p]=[parseFloat(l[0]),parseFloat(l[1]),parseFloat(l[2])]}else e[p]=h}}var c=new THREE.MTLLoader.MaterialCreator(this.texturePath||this.path,this.materialOptions);return c.setCrossOrigin(this.crossOrigin),c.setManager(this.manager),c.setMaterials(s),c}},THREE.MTLLoader.MaterialCreator=function(t,a){this.baseUrl=t||"",this.options=a,this.materialsInfo={},this.materials={},this.materialsArray=[],this.nameLookup={},this.side=this.options&&this.options.side?this.options.side:THREE.FrontSide,this.wrap=this.options&&this.options.wrap?this.options.wrap:THREE.RepeatWrapping},THREE.MTLLoader.MaterialCreator.prototype={constructor:THREE.MTLLoader.MaterialCreator,setCrossOrigin:function(t){this.crossOrigin=t},setManager:function(t){this.manager=t},setMaterials:function(t){this.materialsInfo=this.convert(t),this.materials={},this.materialsArray=[],this.nameLookup={}},convert:function(t){if(!this.options)return t;var a={};for(var e in t){var r=t[e],s={};a[e]=s;for(var i in r){var o=!0,n=r[i],p=i.toLowerCase();switch(p){case"kd":case"ka":case"ks":this.options&&this.options.normalizeRGB&&(n=[n[0]/255,n[1]/255,n[2]/255]),this.options&&this.options.ignoreZeroRGBs&&0===n[0]&&0===n[1]&&0===n[2]&&(o=!1)}o&&(s[p]=n)}}return a},preload:function(){for(var t in this.materialsInfo)this.create(t)},getIndex:function(t){return this.nameLookup[t]},getAsArray:function(){var t=0;for(var a in this.materialsInfo)this.materialsArray[t]=this.create(a),this.nameLookup[a]=t,t++;return this.materialsArray},create:function(t){return void 0===this.materials[t]&&this.createMaterial_(t),this.materials[t]},createMaterial_:function(t){function a(t,a){return"string"!=typeof a||""===a?"":/^https?:\/\//i.test(a)?a:t+a}function e(t,e){if(!i[t]){var s=r.getTextureParams(e,i),o=r.loadTexture(a(r.baseUrl,s.url));o.repeat.copy(s.scale),o.offset.copy(s.offset),o.wrapS=r.wrap,o.wrapT=r.wrap,i[t]=o}}var r=this,s=this.materialsInfo[t],i={name:t,side:this.side};for(var o in s){var n=s[o];if(""!==n)switch(o.toLowerCase()){case"kd":i.color=(new THREE.Color).fromArray(n);break;case"ks":i.specular=(new THREE.Color).fromArray(n);break;case"map_kd":e("map",n);break;case"map_ks":e("specularMap",n);break;case"map_bump":case"bump":e("bumpMap",n);break;case"ns":i.shininess=parseFloat(n);break;case"d":n<1&&(i.opacity=n,i.transparent=!0);break;case"Tr":n>0&&(i.opacity=1-n,i.transparent=!0)}}return this.materials[t]=new THREE.MeshPhongMaterial(i),this.materials[t]},getTextureParams:function(t,a){var e,r={scale:new THREE.Vector2(1,1),offset:new THREE.Vector2(0,0)},s=t.split(/\s+/);return e=s.indexOf("-bm"),e>=0&&(a.bumpScale=parseFloat(s[e+1]),s.splice(e,2)),e=s.indexOf("-s"),e>=0&&(r.scale.set(parseFloat(s[e+1]),parseFloat(s[e+2])),s.splice(e,4)),e=s.indexOf("-o"),e>=0&&(r.offset.set(parseFloat(s[e+1]),parseFloat(s[e+2])),s.splice(e,4)),r.url=s.join(" ").trim(),r},loadTexture:function(t,a,e,r,s){var i;if(altspace&&altspace.inClient)i=new THREE.Texture({src:t});else{var o=THREE.Loader.Handlers.get(t),n=void 0!==this.manager?this.manager:THREE.DefaultLoadingManager;null===o&&(o=new THREE.TextureLoader(n)),o.setCrossOrigin&&o.setCrossOrigin(this.crossOrigin),i=o.load(t,e,r,s)}return void 0!==a&&(i.mapping=a),i}}; -THREE.OBJLoader=function(e){this.manager=void 0!==e?e:THREE.DefaultLoadingManager,this.materials=null,this.regexp={vertex_pattern:/^v\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,normal_pattern:/^vn\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,uv_pattern:/^vt\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,face_vertex:/^f\s+(-?\d+)\s+(-?\d+)\s+(-?\d+)(?:\s+(-?\d+))?/,face_vertex_uv:/^f\s+(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)(?:\s+(-?\d+)\/(-?\d+))?/,face_vertex_uv_normal:/^f\s+(-?\d+)\/(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\/(-?\d+)(?:\s+(-?\d+)\/(-?\d+)\/(-?\d+))?/,face_vertex_normal:/^f\s+(-?\d+)\/\/(-?\d+)\s+(-?\d+)\/\/(-?\d+)\s+(-?\d+)\/\/(-?\d+)(?:\s+(-?\d+)\/\/(-?\d+))?/,object_pattern:/^[og]\s*(.+)?/,smoothing_pattern:/^s\s+(\d+|on|off)/,material_library_pattern:/^mtllib /,material_use_pattern:/^usemtl /}},THREE.OBJLoader.prototype={constructor:THREE.OBJLoader,load:function(e,t,r,a){var i=this,s=new THREE.FileLoader(i.manager);s.setPath(this.path),s.load(e,function(e){t(i.parse(e))},r,a)},setPath:function(e){this.path=e},setMaterials:function(e){this.materials=e},_createParserState:function(){var e={objects:[],object:{},vertices:[],normals:[],uvs:[],materialLibraries:[],startObject:function(e,t){if(this.object&&this.object.fromDeclaration===!1)return this.object.name=e,void(this.object.fromDeclaration=t!==!1);var r=this.object&&"function"==typeof this.object.currentMaterial?this.object.currentMaterial():void 0;if(this.object&&"function"==typeof this.object._finalize&&this.object._finalize(!0),this.object={name:e||"",fromDeclaration:t!==!1,geometry:{vertices:[],normals:[],uvs:[]},materials:[],smooth:!0,startMaterial:function(e,t){var r=this._finalize(!1);r&&(r.inherited||r.groupCount<=0)&&this.materials.splice(r.index,1);var a={index:this.materials.length,name:e||"",mtllib:Array.isArray(t)&&t.length>0?t[t.length-1]:"",smooth:void 0!==r?r.smooth:this.smooth,groupStart:void 0!==r?r.groupEnd:0,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(e){var t={index:"number"==typeof e?e:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return t.clone=this.clone.bind(t),t}};return this.materials.push(a),a},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(e){var t=this.currentMaterial();if(t&&t.groupEnd===-1&&(t.groupEnd=this.geometry.vertices.length/3,t.groupCount=t.groupEnd-t.groupStart,t.inherited=!1),e&&this.materials.length>1)for(var r=this.materials.length-1;r>=0;r--)this.materials[r].groupCount<=0&&this.materials.splice(r,1);return e&&0===this.materials.length&&this.materials.push({name:"",smooth:this.smooth}),t}},r&&r.name&&"function"==typeof r.clone){var a=r.clone(0);a.inherited=!0,this.object.materials.push(a)}this.objects.push(this.object)},finalize:function(){this.object&&"function"==typeof this.object._finalize&&this.object._finalize(!0)},parseVertexIndex:function(e,t){var r=parseInt(e,10);return 3*(r>=0?r-1:r+t/3)},parseNormalIndex:function(e,t){var r=parseInt(e,10);return 3*(r>=0?r-1:r+t/3)},parseUVIndex:function(e,t){var r=parseInt(e,10);return 2*(r>=0?r-1:r+t/2)},addVertex:function(e,t,r){var a=this.vertices,i=this.object.geometry.vertices;i.push(a[e+0]),i.push(a[e+1]),i.push(a[e+2]),i.push(a[t+0]),i.push(a[t+1]),i.push(a[t+2]),i.push(a[r+0]),i.push(a[r+1]),i.push(a[r+2])},addVertexLine:function(e){var t=this.vertices,r=this.object.geometry.vertices;r.push(t[e+0]),r.push(t[e+1]),r.push(t[e+2])},addNormal:function(e,t,r){var a=this.normals,i=this.object.geometry.normals;i.push(a[e+0]),i.push(a[e+1]),i.push(a[e+2]),i.push(a[t+0]),i.push(a[t+1]),i.push(a[t+2]),i.push(a[r+0]),i.push(a[r+1]),i.push(a[r+2])},addUV:function(e,t,r){var a=this.uvs,i=this.object.geometry.uvs;i.push(a[e+0]),i.push(a[e+1]),i.push(a[t+0]),i.push(a[t+1]),i.push(a[r+0]),i.push(a[r+1])},addUVLine:function(e){var t=this.uvs,r=this.object.geometry.uvs;r.push(t[e+0]),r.push(t[e+1])},addFace:function(e,t,r,a,i,s,n,o,h,l,d,u){var p,c=this.vertices.length,m=this.parseVertexIndex(e,c),f=this.parseVertexIndex(t,c),v=this.parseVertexIndex(r,c);if(void 0===a?this.addVertex(m,f,v):(p=this.parseVertexIndex(a,c),this.addVertex(m,f,p),this.addVertex(f,v,p)),void 0!==i){var g=this.uvs.length;m=this.parseUVIndex(i,g),f=this.parseUVIndex(s,g),v=this.parseUVIndex(n,g),void 0===a?this.addUV(m,f,v):(p=this.parseUVIndex(o,g),this.addUV(m,f,p),this.addUV(f,v,p))}if(void 0!==h){var x=this.normals.length;m=this.parseNormalIndex(h,x),f=h===l?m:this.parseNormalIndex(l,x),v=h===d?m:this.parseNormalIndex(d,x),void 0===a?this.addNormal(m,f,v):(p=this.parseNormalIndex(u,x),this.addNormal(m,f,p),this.addNormal(f,v,p))}},addLineGeometry:function(e,t){this.object.geometry.type="Line";for(var r=this.vertices.length,a=this.uvs.length,i=0,s=e.length;i0?V.addAttribute("normal",new THREE.BufferAttribute(new Float32Array(j.normals),3)):V.computeVertexNormals(),j.uvs.length>0&&V.addAttribute("uv",new THREE.BufferAttribute(new Float32Array(j.uvs),2));for(var w=[],H=0,R=y.length;H1){for(var H=0,R=y.length;H0?t:"visual_scene0"]}return null}function n(){var e=Le.querySelectorAll("instance_kinematics_model")[0];if(e){var t=e.getAttribute("url").replace(/^#/,"");return Oe[t.length>0?t:"kinematics_model0"]}return null}function o(){He=[],h(Ve)}function h(e){var t=Ae.getChildById(e.colladaId,!0),i=null;if(t&&t.keys){i={fps:60,hierarchy:[{node:t,keys:t.keys,sids:t.sids}],node:e,name:"animation_"+e.name,length:0},He.push(i);for(var s=0,r=t.keys.length;s=0){var n=t.invBindMatrices[r];s.invBindMatrix=n,s.skinningMatrix=new THREE.Matrix4,s.skinningMatrix.multiplyMatrices(s.world,n),s.animatrix=new THREE.Matrix4,s.animatrix.copy(s.localworld),s.weights=[];for(var a=0;aa.limits.max||i1)for(C=new THREE.MultiMaterial(w),a=0;a0?(C.morphTargets=!0,C.skinning=!1):(C.morphTargets=!1,C.skinning=!0),A=new THREE.SkinnedMesh(H,C,(!1)),A.name="skin_"+qe.length,qe.push(A)):void 0!==s?(c(H,s),C.morphTargets=!0,A=new THREE.Mesh(H,C),A.name="morph_"+Ie.length,Ie.push(A)):A=H.isLineStrip===!0?new THREE.Line(H):new THREE.Mesh(H,C),n.add(A)}}for(r=0;rt)break}return i}function N(e,t){for(var i=-1,s=0,r=e.length;s=t&&(i=s)}return i}function k(e,t,i,s){var r=E(e,s,i?i-1:0),a=T(e,s,i+1);if(r&&a){var n,o=(t.time-r.time)/(a.time-r.time),h=r.getTarget(s),l=a.getTarget(s).data,c=h.data;if("matrix"===h.type)n=c;else if(c.length){n=[];for(var d=0;d=0?i:i+e.length;i>=0;i--){var s=e[i];if(s.hasTarget(t))return s}return null}function R(){this.id="",this.init_from=""}function _(){this.id="",this.name="",this.type="",this.skin=null,this.morph=null}function A(){this.method=null,this.source=null,this.targets=null,this.weights=null}function C(){this.source="",this.bindShapeMatrix=null,this.invBindMatrices=[],this.joints=[],this.weights=[]}function H(){this.id="",this.name="",this.nodes=[],this.scene=new THREE.Group}function M(){this.id="",this.name="",this.sid="",this.nodes=[],this.controllers=[],this.transforms=[],this.geometries=[],this.channels=[],this.matrix=new THREE.Matrix4}function j(){this.sid="",this.type="",this.data=[],this.obj=null}function O(){this.url="",this.skeleton=[],this.instance_material=[]}function S(){this.symbol="",this.target=""}function I(){this.url="",this.instance_material=[]}function q(){this.id="",this.mesh=null}function L(e){this.geometry=e.id,this.primitives=[],this.vertices=null,this.geometry3js=null}function V(){this.material="",this.count=0,this.inputs=[],this.vcount=null,this.p=[],this.geometry=new THREE.Geometry}function X(){V.call(this),this.vcount=[]}function Y(){V.call(this),this.vcount=1}function Z(){V.call(this),this.vcount=3}function z(){this.source="",this.count=0,this.stride=0,this.params=[]}function F(){this.input={}}function U(){this.semantic="",this.offset=0,this.source="",this.set=0}function B(e){this.id=e,this.type=null}function D(){this.id="",this.name="",this.instance_effect=null}function P(){this.color=new THREE.Color,this.color.setRGB(Math.random(),Math.random(),Math.random()),this.color.a=1,this.texture=null,this.texcoord=null,this.texOpts=null}function G(e,t){this.type=e,this.effect=t,this.material=null}function J(e){this.effect=e,this.init_from=null,this.format=null}function W(e){this.effect=e,this.source=null,this.wrap_s=null,this.wrap_t=null,this.minfilter=null,this.magfilter=null,this.mipfilter=null}function Q(){this.id="",this.name="",this.shader=null,this.surface={},this.sampler={}}function $(){this.url=""}function K(){this.id="",this.name="",this.source={},this.sampler=[],this.channel=[]}function ee(e){this.animation=e,this.source="",this.target="",this.fullSid=null,this.sid=null,this.dotSyntax=null,this.arrSyntax=null,this.arrIndices=null,this.member=null}function te(e){this.id="",this.animation=e,this.inputs=[],this.input=null,this.output=null,this.strideOut=null,this.interpolation=null,this.startTime=null,this.endTime=null,this.duration=0}function ie(e){this.targets=[],this.time=e}function se(){this.id="",this.name="",this.technique=""}function re(){this.url=""}function ae(){this.id="",this.name="",this.technique=""}function ne(){this.url=""}function oe(){this.id="",this.name="",this.joints=[],this.links=[]}function he(){this.sid="",this.name="",this.axis=new THREE.Vector3,this.limits={min:0,max:0},this.type="",this.static=!1,this.zeroPosition=0,this.middlePosition=0}function le(){this.sid="",this.name="",this.transforms=[],this.attachments=[]}function ce(){this.joint="",this.transforms=[],this.links=[]}function de(e){var t=e.getAttribute("id");return void 0!=Ye[t]?Ye[t]:(Ye[t]=new B(t).parse(e),Ye[t])}function pe(e){for(var t=me(e),i=[],s=0,r=t.length;s0?ge(e).split(/\s+/):[]}function ge(e){return e.replace(/^\s+/,"").replace(/\s+$/,"")}function ve(e,t,i){return e.hasAttribute(t)?parseInt(e.getAttribute(t),10):i}function ye(e,t){if("string"!=typeof e||""===e)return"";if(/^(https?:)?\/\//i.test(e))return e;if(/^data:.*,.*$/i.test(e))return e;var i=new URL((t||"")+e,location.href.substring(0,location.href.lastIndexOf("/")+1));return i.toString()}function be(e,t){var i=new THREE.ImageLoader;i.load(t,function(t){e.image=t,e.needsUpdate=!0})}function we(e,t){e.doubleSided=!1;var i=t.querySelectorAll("extra double_sided")[0];i&&i&&1===parseInt(i.textContent,10)&&(e.doubleSided=!0)}function xe(){if(We.convertUpAxis!==!0||$e===We.upAxis)Ke=null;else switch($e){case"X":Ke="Y"===We.upAxis?"XtoY":"XtoZ";break;case"Y":Ke="X"===We.upAxis?"YtoX":"YtoZ";break;case"Z":Ke="X"===We.upAxis?"ZtoX":"ZtoY"}}function Ne(e,t){if(We.convertUpAxis===!0&&$e!==We.upAxis)switch(Ke){case"XtoY":var i=e[0];e[0]=t*e[1],e[1]=i;break;case"XtoZ":var i=e[2];e[2]=e[1],e[1]=e[0],e[0]=i;break;case"YtoX":var i=e[0];e[0]=e[1],e[1]=t*i;break;case"YtoZ":var i=e[1];e[1]=t*e[2],e[2]=i;break;case"ZtoX":var i=e[0];e[0]=e[1],e[1]=e[2],e[2]=i;break;case"ZtoY":var i=e[1];e[1]=e[2],e[2]=t*i}}function ke(e,t){if(We.convertUpAxis!==!0||$e===We.upAxis)return t;switch(e){case"X":t="XtoY"===Ke?t*-1:t;break;case"Y":t="YtoZ"===Ke||"YtoX"===Ke?t*-1:t;break;case"Z":t="ZtoY"===Ke?t*-1:t}return t}function Te(e,t){var i=[e[t],e[t+1],e[t+2]];return Ne(i,-1),new THREE.Vector3(i[0],i[1],i[2])}function Ee(e){if(We.convertUpAxis){var t=[e[0],e[4],e[8]];Ne(t,-1),e[0]=t[0],e[4]=t[1],e[8]=t[2],t=[e[1],e[5],e[9]],Ne(t,-1),e[1]=t[0],e[5]=t[1],e[9]=t[2],t=[e[2],e[6],e[10]],Ne(t,-1),e[2]=t[0],e[6]=t[1],e[10]=t[2],t=[e[0],e[1],e[2]],Ne(t,-1),e[0]=t[0],e[1]=t[1],e[2]=t[2],t=[e[4],e[5],e[6]],Ne(t,-1),e[4]=t[0],e[5]=t[1],e[6]=t[2],t=[e[8],e[9],e[10]],Ne(t,-1),e[8]=t[0],e[9]=t[1],e[10]=t[2],t=[e[3],e[7],e[11]],Ne(t,-1),e[3]=t[0],e[7]=t[1],e[11]=t[2]}return(new THREE.Matrix4).set(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15])}function Re(e){if(e>-1&&e<3){var t=["X","Y","Z"],i={X:0,Y:1,Z:2};e=_e(t[e]),e=i[e]}return e}function _e(e){if(We.convertUpAxis)switch(e){case"X":switch(Ke){case"XtoY":case"XtoZ":case"YtoX":e="Y";break;case"ZtoX":e="Z"}break;case"Y":switch(Ke){case"XtoY":case"YtoX":case"ZtoX":e="X";break;case"XtoZ":case"YtoZ":case"ZtoY":e="Z"}break;case"Z":switch(Ke){case"XtoZ":e="X";break;case"YtoZ":case"ZtoX":case"ZtoY":e="Y"}}return e}var Ae,Ce,He,Me,je,Oe,Se,Ie,qe,Le=null,Ve=null,Xe=null,Ye={},Ze={},ze={},Fe={},Ue={},Be={},De={},Pe={},Ge={},Je=THREE.SmoothShading,We={centerGeometry:!1,convertUpAxis:!1,subdivideFaces:!0,upAxis:"Y",defaultEnvMap:null},Qe=1,$e="Y",Ke=null;return R.prototype.parse=function(e){this.id=e.getAttribute("id");for(var t=0;t=0,h=n.indexOf("(")>=0;if(o)a=n.split("."),n=a.shift(),s=a.shift();else if(h){i=n.split("("),n=i.shift();for(var l=0;l4&&We.subdivideFaces){var C=N.length?N:new THREE.Color;for(s=1;s4?[E[0],E[k+1],E[k+2]]:4===p?0===k?[E[0],E[1],E[3]]:[E[1].clone(),E[2],E[3].clone()]:[E[0],E[1],E[2]],void 0===t.faceVertexUvs[s]&&(t.faceVertexUvs[s]=[]),t.faceVertexUvs[s].push(R);else console.log("dropped face with vcount "+p+" for geometry with id: "+t.id);y+=u*p}},V.prototype.setVertices=function(e){for(var t=0;t0&&(this[i.nodeName]=parseFloat(r[0].textContent))}}return this.create(),this},G.prototype.create=function(){var e={},t=!1;if(void 0!==this.transparency&&void 0!==this.transparent){var i=(this.transparent,(this.transparent.color.r+this.transparent.color.g+this.transparent.color.b)/3*this.transparency);i>0&&(t=!0,e.transparent=!0,e.opacity=1-i)}var s={diffuse:"map",ambient:"lightMap",specular:"specularMap",emission:"emissionMap",bump:"bumpMap",normal:"normalMap"};for(var r in this)switch(r){case"ambient":case"emission":case"diffuse":case"specular":case"bump":case"normal":var a=this[r];if(a instanceof P)if(a.isTexture()){var n=a.texture,o=this.effect.sampler[n];if(void 0!==o&&void 0!==o.source){var h=this.effect.surface[o.source];if(void 0!==h){var l=Ze[h.init_from];if(l){var c,d=Se+l.init_from;if(altspace&&altspace.inClient)c=new THREE.Texture({src:ye(d)});else{var p=THREE.Loader.Handlers.get(d);null!==p?c=p.load(d):(c=new THREE.Texture,be(c,d))}"MIRROR"===o.wrap_s?c.wrapS=THREE.MirroredRepeatWrapping:"WRAP"===o.wrap_s||a.texOpts.wrapU?c.wrapS=THREE.RepeatWrapping:c.wrapS=THREE.ClampToEdgeWrapping,"MIRROR"===o.wrap_t?c.wrapT=THREE.MirroredRepeatWrapping:"WRAP"===o.wrap_t||a.texOpts.wrapV?c.wrapT=THREE.RepeatWrapping:c.wrapT=THREE.ClampToEdgeWrapping,c.offset.x=a.texOpts.offsetU,c.offset.y=a.texOpts.offsetV,c.repeat.x=a.texOpts.repeatU,c.repeat.y=a.texOpts.repeatV,e[s[r]]=c,"emission"===r&&(e.emissive=16777215)}}}}else"diffuse"!==r&&t||("emission"===r?e.emissive=a.color.getHex():e[r]=a.color.getHex());break;case"shininess":e[r]=this[r];break;case"reflectivity":e[r]=this[r],e[r]>0&&(e.envMap=We.defaultEnvMap),e.combine=THREE.MixOperation;break;case"index_of_refraction":e.refractionRatio=this[r],1!==this[r]&&(e.envMap=We.defaultEnvMap);break;case"transparency":}switch(e.shading=Je,e.side=this.effect.doubleSided?THREE.DoubleSide:THREE.FrontSide,void 0!==e.diffuse&&(e.color=e.diffuse,delete e.diffuse),this.type){case"constant":void 0!=e.emissive&&(e.color=e.emissive),this.material=new THREE.MeshBasicMaterial(e);break;case"phong":case"blinn":this.material=new THREE.MeshPhongMaterial(e);break;case"lambert":default:this.material=new THREE.MeshLambertMaterial(e)}return this.material},J.prototype.parse=function(e){for(var t=0;t=0,r=i.indexOf("(")>=0;if(s)t=i.split("."),this.sid=t.shift(),this.member=t.shift();else if(r){var a=i.split("(");this.sid=a.shift();for(var n=0;n1){s=[],t*=this.strideOut;for(var r=0;r1&&(o=1),l.length){r=[];for(var c=0;c=this.limits.max&&(this.static=!0),this.middlePosition=(this.limits.min+this.limits.max)/2,this},le.prototype.parse=function(e){this.sid=e.getAttribute("sid"),this.name=e.getAttribute("name"),this.transforms=[],this.attachments=[];for(var t=0;t=0&&(s[d.KHR_MATERIALS_COMMON]=new n(u)),console.time("GLTFLoader");var p=new E(u,s,{path:t||this.path,crossOrigin:this.crossOrigin});p.parse(function(e,t,n,a){console.log("------------ UltimateLoader ---------------"),console.timeEnd("GLTFLoader");var i={scene:e,scenes:t,cameras:n,animations:a};r(i)})}},e.Shaders={update:function(){console.warn("THREE.GLTFLoader.Shaders has been deprecated, and now updates automatically.")}},t.prototype.update=function(e,r){var t=this.boundUniforms;for(var n in t){var a=t[n];switch(a.semantic){case"MODELVIEW":var i=a.uniform.value;i.multiplyMatrices(r.matrixWorldInverse,a.sourceNode.matrixWorld);break;case"MODELVIEWINVERSETRANSPOSE":var s=a.uniform.value;this._m4.multiplyMatrices(r.matrixWorldInverse,a.sourceNode.matrixWorld),s.getNormalMatrix(this._m4);break;case"PROJECTION":var i=a.uniform.value;i.copy(r.projectionMatrix);break;case"JOINTMATRIX":for(var o=a.uniform.value,c=0;c=0?n.substring(0,o):n;l=l.toLowerCase();var c=o>=0?n.substring(o+1):"";if(c=c.trim(),"newmtl"===l)r={name:c},i[c]=r;else if(r)if("ka"===l||"kd"===l||"ks"===l){var h=c.split(a,3);r[l]=[parseFloat(h[0]),parseFloat(h[1]),parseFloat(h[2])]}else r[l]=c}}var u=new THREE.MTLLoader.MaterialCreator(this.texturePath||this.path,this.materialOptions);return u.setCrossOrigin(this.crossOrigin),u.setManager(this.manager),u.setMaterials(i),u}},THREE.MTLLoader.MaterialCreator=function(e,t){this.baseUrl=e||"",this.options=t,this.materialsInfo={},this.materials={},this.materialsArray=[],this.nameLookup={},this.side=this.options&&this.options.side?this.options.side:THREE.FrontSide,this.wrap=this.options&&this.options.wrap?this.options.wrap:THREE.RepeatWrapping},THREE.MTLLoader.MaterialCreator.prototype={constructor:THREE.MTLLoader.MaterialCreator,setCrossOrigin:function(e){this.crossOrigin=e},setManager:function(e){this.manager=e},setMaterials:function(e){this.materialsInfo=this.convert(e),this.materials={},this.materialsArray=[],this.nameLookup={}},convert:function(e){if(!this.options)return e;var t={};for(var r in e){var a=e[r],i={};t[r]=i;for(var s in a){var n=!0,o=a[s],l=s.toLowerCase();switch(l){case"kd":case"ka":case"ks":this.options&&this.options.normalizeRGB&&(o=[o[0]/255,o[1]/255,o[2]/255]),this.options&&this.options.ignoreZeroRGBs&&0===o[0]&&0===o[1]&&0===o[2]&&(n=!1)}n&&(i[l]=o)}}return t},preload:function(){for(var e in this.materialsInfo)this.create(e)},getIndex:function(e){return this.nameLookup[e]},getAsArray:function(){var e=0;for(var t in this.materialsInfo)this.materialsArray[e]=this.create(t),this.nameLookup[t]=e,e++;return this.materialsArray},create:function(e){return void 0===this.materials[e]&&this.createMaterial_(e),this.materials[e]},createMaterial_:function(e){function t(e,t){return"string"!=typeof t||""===t?"":/^https?:\/\//i.test(t)?t:e+t}function r(e,r){if(!s[e]){var i=a.getTextureParams(r,s),n=a.loadTexture(t(a.baseUrl,i.url));n.repeat.copy(i.scale),n.offset.copy(i.offset),n.wrapS=a.wrap,n.wrapT=a.wrap,s[e]=n}}var a=this,i=this.materialsInfo[e],s={name:e,side:this.side};for(var n in i){var o=i[n];if(""!==o)switch(n.toLowerCase()){case"kd":s.color=(new THREE.Color).fromArray(o);break;case"ks":s.specular=(new THREE.Color).fromArray(o);break;case"map_kd":r("map",o);break;case"map_ks":r("specularMap",o);break;case"map_bump":case"bump":r("bumpMap",o);break;case"ns":s.shininess=parseFloat(o);break;case"d":o<1&&(s.opacity=o,s.transparent=!0);break;case"Tr":o>0&&(s.opacity=1-o,s.transparent=!0)}}return this.materials[e]=new THREE.MeshPhongMaterial(s),this.materials[e]},getTextureParams:function(e,t){var r,a={scale:new THREE.Vector2(1,1),offset:new THREE.Vector2(0,0)},i=e.split(/\s+/);return r=i.indexOf("-bm"),r>=0&&(t.bumpScale=parseFloat(i[r+1]),i.splice(r,2)),r=i.indexOf("-s"),r>=0&&(a.scale.set(parseFloat(i[r+1]),parseFloat(i[r+2])),i.splice(r,4)),r=i.indexOf("-o"),r>=0&&(a.offset.set(parseFloat(i[r+1]),parseFloat(i[r+2])),i.splice(r,4)),a.url=i.join(" ").trim(),a},loadTexture:function(e,t,r,a,i){var s;if(altspace&&altspace.inClient)s=new THREE.Texture({src:e});else{var n=THREE.Loader.Handlers.get(e),o=void 0!==this.manager?this.manager:THREE.DefaultLoadingManager;null===n&&(n=new THREE.TextureLoader(o)),n.setCrossOrigin&&n.setCrossOrigin(this.crossOrigin),s=n.load(e,r,a,i)}return void 0!==t&&(s.mapping=t),s}},THREE.OBJLoader=function(e){this.manager=void 0!==e?e:THREE.DefaultLoadingManager,this.materials=null,this.regexp={vertex_pattern:/^v\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,normal_pattern:/^vn\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,uv_pattern:/^vt\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,face_vertex:/^f\s+(-?\d+)\s+(-?\d+)\s+(-?\d+)(?:\s+(-?\d+))?/,face_vertex_uv:/^f\s+(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)(?:\s+(-?\d+)\/(-?\d+))?/,face_vertex_uv_normal:/^f\s+(-?\d+)\/(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\/(-?\d+)(?:\s+(-?\d+)\/(-?\d+)\/(-?\d+))?/,face_vertex_normal:/^f\s+(-?\d+)\/\/(-?\d+)\s+(-?\d+)\/\/(-?\d+)\s+(-?\d+)\/\/(-?\d+)(?:\s+(-?\d+)\/\/(-?\d+))?/,object_pattern:/^[og]\s*(.+)?/,smoothing_pattern:/^s\s+(\d+|on|off)/,material_library_pattern:/^mtllib /,material_use_pattern:/^usemtl /}},THREE.OBJLoader.prototype={constructor:THREE.OBJLoader,load:function(e,t,r,a){var i=this,s=new THREE.FileLoader(i.manager);s.setPath(this.path),s.load(e,function(e){t(i.parse(e))},r,a)},setPath:function(e){this.path=e},setMaterials:function(e){this.materials=e},_createParserState:function(){var e={objects:[],object:{},vertices:[],normals:[],uvs:[],materialLibraries:[],startObject:function(e,t){if(this.object&&this.object.fromDeclaration===!1)return this.object.name=e,void(this.object.fromDeclaration=t!==!1);var r=this.object&&"function"==typeof this.object.currentMaterial?this.object.currentMaterial():void 0;if(this.object&&"function"==typeof this.object._finalize&&this.object._finalize(!0),this.object={name:e||"",fromDeclaration:t!==!1,geometry:{vertices:[],normals:[],uvs:[]},materials:[],smooth:!0,startMaterial:function(e,t){var r=this._finalize(!1);r&&(r.inherited||r.groupCount<=0)&&this.materials.splice(r.index,1);var a={index:this.materials.length,name:e||"",mtllib:Array.isArray(t)&&t.length>0?t[t.length-1]:"",smooth:void 0!==r?r.smooth:this.smooth,groupStart:void 0!==r?r.groupEnd:0,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(e){var t={index:"number"==typeof e?e:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return t.clone=this.clone.bind(t),t}};return this.materials.push(a),a},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(e){var t=this.currentMaterial();if(t&&t.groupEnd===-1&&(t.groupEnd=this.geometry.vertices.length/3,t.groupCount=t.groupEnd-t.groupStart,t.inherited=!1),e&&this.materials.length>1)for(var r=this.materials.length-1;r>=0;r--)this.materials[r].groupCount<=0&&this.materials.splice(r,1);return e&&0===this.materials.length&&this.materials.push({name:"",smooth:this.smooth}),t}},r&&r.name&&"function"==typeof r.clone){var a=r.clone(0);a.inherited=!0,this.object.materials.push(a)}this.objects.push(this.object)},finalize:function(){this.object&&"function"==typeof this.object._finalize&&this.object._finalize(!0)},parseVertexIndex:function(e,t){var r=parseInt(e,10);return 3*(r>=0?r-1:r+t/3)},parseNormalIndex:function(e,t){var r=parseInt(e,10);return 3*(r>=0?r-1:r+t/3)},parseUVIndex:function(e,t){var r=parseInt(e,10);return 2*(r>=0?r-1:r+t/2)},addVertex:function(e,t,r){var a=this.vertices,i=this.object.geometry.vertices;i.push(a[e+0]),i.push(a[e+1]),i.push(a[e+2]),i.push(a[t+0]),i.push(a[t+1]),i.push(a[t+2]),i.push(a[r+0]),i.push(a[r+1]),i.push(a[r+2])},addVertexLine:function(e){var t=this.vertices,r=this.object.geometry.vertices;r.push(t[e+0]),r.push(t[e+1]),r.push(t[e+2])},addNormal:function(e,t,r){var a=this.normals,i=this.object.geometry.normals;i.push(a[e+0]),i.push(a[e+1]),i.push(a[e+2]),i.push(a[t+0]),i.push(a[t+1]),i.push(a[t+2]),i.push(a[r+0]),i.push(a[r+1]),i.push(a[r+2])},addUV:function(e,t,r){var a=this.uvs,i=this.object.geometry.uvs;i.push(a[e+0]),i.push(a[e+1]),i.push(a[t+0]),i.push(a[t+1]),i.push(a[r+0]),i.push(a[r+1])},addUVLine:function(e){var t=this.uvs,r=this.object.geometry.uvs;r.push(t[e+0]),r.push(t[e+1])},addFace:function(e,t,r,a,i,s,n,o,l,c,h,u){var d,p=this.vertices.length,f=this.parseVertexIndex(e,p),m=this.parseVertexIndex(t,p),E=this.parseVertexIndex(r,p);if(void 0===a?this.addVertex(f,m,E):(d=this.parseVertexIndex(a,p),this.addVertex(f,m,d),this.addVertex(m,E,d)),void 0!==i){var v=this.uvs.length;f=this.parseUVIndex(i,v),m=this.parseUVIndex(s,v),E=this.parseUVIndex(n,v),void 0===a?this.addUV(f,m,E):(d=this.parseUVIndex(o,v),this.addUV(f,m,d),this.addUV(m,E,d))}if(void 0!==l){var g=this.normals.length;f=this.parseNormalIndex(l,g),m=l===c?f:this.parseNormalIndex(c,g),E=l===h?f:this.parseNormalIndex(h,g),void 0===a?this.addNormal(f,m,E):(d=this.parseNormalIndex(u,g),this.addNormal(f,m,d),this.addNormal(m,E,d))}},addLineGeometry:function(e,t){this.object.geometry.type="Line";for(var r=this.vertices.length,a=this.uvs.length,i=0,s=e.length;i0?A.addAttribute("normal",new THREE.BufferAttribute(new Float32Array(R.normals),3)):A.computeVertexNormals(),R.uvs.length>0&&A.addAttribute("uv",new THREE.BufferAttribute(new Float32Array(R.uvs),2));for(var N=[],M=0,H=w.length;M1){for(var M=0,H=w.length;M0?t:"visual_scene0"]}return null}function n(){var e=Fe.querySelectorAll("instance_kinematics_model")[0];if(e){var t=e.getAttribute("url").replace(/^#/,"");return ke[t.length>0?t:"kinematics_model0"]}return null}function o(){_e=[],l(Pe)}function l(e){var t=He.getChildById(e.colladaId,!0),r=null;if(t&&t.keys){r={fps:60,hierarchy:[{node:t,keys:t.keys,sids:t.sids}],node:e,name:"animation_"+e.name,length:0},_e.push(r);for(var a=0,i=t.keys.length;a=0){var n=t.invBindMatrices[i];a.invBindMatrix=n,a.skinningMatrix=new THREE.Matrix4,a.skinningMatrix.multiplyMatrices(a.world,n),a.animatrix=new THREE.Matrix4,a.animatrix.copy(a.localworld),a.weights=[];for(var s=0;ss.limits.max||r1)for(L=new THREE.MultiMaterial(b),s=0;s<_.faces.length;s++){var S=_.faces[s];S.materialIndex=T[S.daeMaterial]}void 0!==r?(m(_,r),_.morphTargets.length>0?(L.morphTargets=!0,L.skinning=!1):(L.morphTargets=!1,L.skinning=!0),H=new THREE.SkinnedMesh(_,L,!1),H.name="skin_"+je.length,je.push(H)):void 0!==a?(h(_,a),L.morphTargets=!0,H=new THREE.Mesh(_,L),H.name="morph_"+Ie.length,Ie.push(H)):H=_.isLineStrip===!0?new THREE.Line(_):new THREE.Mesh(_,L),n.add(H)}}for(i=0;it)break}return r}function R(e,t){for(var r=-1,a=0,i=e.length;a=t&&(r=a)}return r}function w(e,t,r,a){var i=A(e,a,r?r-1:0),s=x(e,a,r+1);if(i&&s){var n,o=(t.time-i.time)/(s.time-i.time),l=i.getTarget(a),c=s.getTarget(a).data,h=l.data;if("matrix"===l.type)n=h;else if(h.length){n=[];for(var u=0;u=0?r:r+e.length;r>=0;r--){var a=e[r];if(a.hasTarget(t))return a}return null}function N(){this.id="",this.init_from=""}function M(){this.id="",this.name="",this.type="",this.skin=null,this.morph=null}function H(){this.method=null,this.source=null,this.targets=null,this.weights=null}function L(){this.source="",this.bindShapeMatrix=null,this.invBindMatrices=[],this.joints=[],this.weights=[]}function _(){this.id="",this.name="",this.nodes=[],this.scene=new THREE.Group}function S(){this.id="",this.name="",this.sid="",this.nodes=[],this.controllers=[],this.transforms=[],this.geometries=[],this.channels=[],this.matrix=new THREE.Matrix4}function O(){this.sid="",this.type="",this.data=[],this.obj=null}function k(){this.url="",this.skeleton=[],this.instance_material=[]}function C(){this.symbol="",this.target=""}function I(){this.url="",this.instance_material=[]}function j(){this.id="",this.mesh=null}function F(e){this.geometry=e.id,this.primitives=[],this.vertices=null,this.geometry3js=null}function P(){this.material="",this.count=0,this.inputs=[],this.vcount=null,this.p=[],this.geometry=new THREE.Geometry}function U(){P.call(this),this.vcount=[]}function B(){P.call(this),this.vcount=1}function D(){P.call(this),this.vcount=3}function V(){this.source="",this.count=0,this.stride=0,this.params=[]}function G(){this.input={}}function Y(){this.semantic="",this.offset=0,this.source="",this.set=0}function q(e){this.id=e,this.type=null}function z(){this.id="",this.name="",this.instance_effect=null}function X(){this.color=new THREE.Color,this.color.setRGB(Math.random(),Math.random(),Math.random()),this.color.a=1,this.texture=null,this.texcoord=null,this.texOpts=null}function W(e,t){this.type=e,this.effect=t,this.material=null}function Z(e){this.effect=e,this.init_from=null,this.format=null}function K(e){this.effect=e,this.source=null,this.wrap_s=null,this.wrap_t=null,this.minfilter=null,this.magfilter=null,this.mipfilter=null}function J(){this.id="",this.name="",this.shader=null,this.surface={},this.sampler={}}function Q(){this.url=""}function $(){this.id="",this.name="",this.source={},this.sampler=[],this.channel=[]}function ee(e){this.animation=e,this.source="",this.target="",this.fullSid=null,this.sid=null,this.dotSyntax=null,this.arrSyntax=null,this.arrIndices=null,this.member=null}function te(e){this.id="",this.animation=e,this.inputs=[],this.input=null,this.output=null,this.strideOut=null,this.interpolation=null,this.startTime=null,this.endTime=null,this.duration=0}function re(e){this.targets=[],this.time=e}function ae(){this.id="",this.name="",this.technique=""}function ie(){this.url=""}function se(){this.id="",this.name="",this.technique=""}function ne(){this.url=""}function oe(){this.id="",this.name="",this.joints=[],this.links=[]}function le(){this.sid="",this.name="",this.axis=new THREE.Vector3,this.limits={min:0,max:0},this.type="",this.static=!1,this.zeroPosition=0,this.middlePosition=0}function ce(){this.sid="",this.name="",this.transforms=[],this.attachments=[]}function he(){this.joint="",this.transforms=[],this.links=[]}function ue(e){var t=e.getAttribute("id");return void 0!=Be[t]?Be[t]:(Be[t]=new q(t).parse(e),Be[t])}function de(e){for(var t=me(e),r=[],a=0,i=t.length;a0?Ee(e).split(/\s+/):[]}function Ee(e){return e.replace(/^\s+/,"").replace(/\s+$/,"")}function ve(e,t,r){return e.hasAttribute(t)?parseInt(e.getAttribute(t),10):r}function ge(e,t){if("string"!=typeof e||""===e)return"";if(/^(https?:)?\/\//i.test(e))return e;if(/^data:.*,.*$/i.test(e))return e;var r=new URL((t||"")+e,location.href.substring(0,location.href.lastIndexOf("/")+1));return r.toString()}function Te(e,t){var r=new THREE.ImageLoader;r.load(t,function(t){e.image=t,e.needsUpdate=!0})}function be(e,t){e.doubleSided=!1;var r=t.querySelectorAll("extra double_sided")[0];r&&r&&1===parseInt(r.textContent,10)&&(e.doubleSided=!0)}function ye(){if(Ke.convertUpAxis!==!0||Qe===Ke.upAxis)$e=null;else switch(Qe){case"X":$e="Y"===Ke.upAxis?"XtoY":"XtoZ";break;case"Y":$e="X"===Ke.upAxis?"YtoX":"YtoZ";break;case"Z":$e="X"===Ke.upAxis?"ZtoX":"ZtoY"}}function Re(e,t){if(Ke.convertUpAxis===!0&&Qe!==Ke.upAxis)switch($e){case"XtoY":var r=e[0];e[0]=t*e[1],e[1]=r;break;case"XtoZ":var r=e[2];e[2]=e[1],e[1]=e[0],e[0]=r;break;case"YtoX":var r=e[0];e[0]=e[1],e[1]=t*r;break;case"YtoZ":var r=e[1];e[1]=t*e[2],e[2]=r;break;case"ZtoX":var r=e[0];e[0]=e[1],e[1]=e[2],e[2]=r;break;case"ZtoY":var r=e[1];e[1]=e[2],e[2]=t*r}}function we(e,t){if(Ke.convertUpAxis!==!0||Qe===Ke.upAxis)return t;switch(e){case"X":t="XtoY"===$e?t*-1:t;break;case"Y":t="YtoZ"===$e||"YtoX"===$e?t*-1:t;break;case"Z":t="ZtoY"===$e?t*-1:t}return t}function xe(e,t){var r=[e[t],e[t+1],e[t+2]];return Re(r,-1),new THREE.Vector3(r[0],r[1],r[2])}function Ae(e){if(Ke.convertUpAxis){var t=[e[0],e[4],e[8]];Re(t,-1),e[0]=t[0],e[4]=t[1],e[8]=t[2],t=[e[1],e[5],e[9]],Re(t,-1),e[1]=t[0],e[5]=t[1],e[9]=t[2],t=[e[2],e[6],e[10]],Re(t,-1),e[2]=t[0],e[6]=t[1],e[10]=t[2],t=[e[0],e[1],e[2]],Re(t,-1),e[0]=t[0],e[1]=t[1],e[2]=t[2],t=[e[4],e[5],e[6]],Re(t,-1),e[4]=t[0],e[5]=t[1],e[6]=t[2],t=[e[8],e[9],e[10]],Re(t,-1),e[8]=t[0],e[9]=t[1],e[10]=t[2],t=[e[3],e[7],e[11]],Re(t,-1),e[3]=t[0],e[7]=t[1],e[11]=t[2]}return(new THREE.Matrix4).set(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15])}function Ne(e){if(e>-1&&e<3){var t=["X","Y","Z"],r={X:0,Y:1,Z:2};e=Me(t[e]),e=r[e]}return e}function Me(e){if(Ke.convertUpAxis)switch(e){case"X":switch($e){case"XtoY":case"XtoZ":case"YtoX":e="Y";break;case"ZtoX":e="Z"}break;case"Y":switch($e){case"XtoY":case"YtoX":case"ZtoX":e="X";break;case"XtoZ":case"YtoZ":case"ZtoY":e="Z"}break;case"Z":switch($e){case"XtoZ":e="X";break;case"YtoZ":case"ZtoX":case"ZtoY":e="Y"}}return e}var He,Le,_e,Se,Oe,ke,Ce,Ie,je,Fe=null,Pe=null,Ue=null,Be={},De={},Ve={},Ge={},Ye={},qe={},ze={},Xe={},We={},Ze=THREE.SmoothShading,Ke={centerGeometry:!1,convertUpAxis:!1,subdivideFaces:!0,upAxis:"Y",defaultEnvMap:null},Je=1,Qe="Y",$e=null;return N.prototype.parse=function(e){this.id=e.getAttribute("id");for(var t=0;t=0,l=n.indexOf("(")>=0;if(o)s=n.split("."),n=s.shift(),a=s.shift();else if(l){r=n.split("("),n=r.shift();for(var c=0;c4&&Ke.subdivideFaces){var L=R.length?R:new THREE.Color;for(a=1;a4?[A[0],A[w+1],A[w+2]]:4===d?0===w?[A[0],A[1],A[3]]:[A[1].clone(),A[2],A[3].clone()]:[A[0],A[1],A[2]],void 0===t.faceVertexUvs[a]&&(t.faceVertexUvs[a]=[]),t.faceVertexUvs[a].push(N);else console.log("dropped face with vcount "+d+" for geometry with id: "+t.id);g+=p*d}},P.prototype.setVertices=function(e){for(var t=0;t0&&(this[r.nodeName]=parseFloat(i[0].textContent))}}return this.create(),this},W.prototype.create=function(){var e={},t=!1;if(void 0!==this.transparency&&void 0!==this.transparent){var r=(this.transparent,(this.transparent.color.r+this.transparent.color.g+this.transparent.color.b)/3*this.transparency);r>0&&(t=!0,e.transparent=!0,e.opacity=1-r)}var a={diffuse:"map",ambient:"lightMap",specular:"specularMap",emission:"emissionMap",bump:"bumpMap",normal:"normalMap"};for(var i in this)switch(i){case"ambient":case"emission":case"diffuse":case"specular":case"bump":case"normal":var s=this[i];if(s instanceof X)if(s.isTexture()){var n=s.texture,o=this.effect.sampler[n];if(void 0!==o&&void 0!==o.source){var l=this.effect.surface[o.source];if(void 0!==l){var c=De[l.init_from];if(c){var h,u=Ce+c.init_from;if(altspace&&altspace.inClient)h=new THREE.Texture({src:ge(u)});else{var d=THREE.Loader.Handlers.get(u);null!==d?h=d.load(u):(h=new THREE.Texture,Te(h,u))}"MIRROR"===o.wrap_s?h.wrapS=THREE.MirroredRepeatWrapping:"WRAP"===o.wrap_s||s.texOpts.wrapU?h.wrapS=THREE.RepeatWrapping:h.wrapS=THREE.ClampToEdgeWrapping,"MIRROR"===o.wrap_t?h.wrapT=THREE.MirroredRepeatWrapping:"WRAP"===o.wrap_t||s.texOpts.wrapV?h.wrapT=THREE.RepeatWrapping:h.wrapT=THREE.ClampToEdgeWrapping,h.offset.x=s.texOpts.offsetU,h.offset.y=s.texOpts.offsetV,h.repeat.x=s.texOpts.repeatU,h.repeat.y=s.texOpts.repeatV,e[a[i]]=h,"emission"===i&&(e.emissive=16777215)}}}}else"diffuse"!==i&&t||("emission"===i?e.emissive=s.color.getHex():e[i]=s.color.getHex());break;case"shininess":e[i]=this[i];break;case"reflectivity":e[i]=this[i],e[i]>0&&(e.envMap=Ke.defaultEnvMap),e.combine=THREE.MixOperation;break;case"index_of_refraction":e.refractionRatio=this[i],1!==this[i]&&(e.envMap=Ke.defaultEnvMap);break;case"transparency":}switch(e.shading=Ze,e.side=this.effect.doubleSided?THREE.DoubleSide:THREE.FrontSide,void 0!==e.diffuse&&(e.color=e.diffuse,delete e.diffuse),this.type){case"constant":void 0!=e.emissive&&(e.color=e.emissive),this.material=new THREE.MeshBasicMaterial(e);break;case"phong":case"blinn":this.material=new THREE.MeshPhongMaterial(e);break;case"lambert":default:this.material=new THREE.MeshLambertMaterial(e)}return this.material},Z.prototype.parse=function(e){for(var t=0;t=0,i=r.indexOf("(")>=0;if(a)t=r.split("."),this.sid=t.shift(),this.member=t.shift();else if(i){var s=r.split("(");this.sid=s.shift();for(var n=0;n1){a=[],t*=this.strideOut;for(var i=0;i1&&(o=1),c.length){i=[];for(var h=0;h=this.limits.max&&(this.static=!0),this.middlePosition=(this.limits.min+this.limits.max)/2,this},ce.prototype.parse=function(e){this.sid=e.getAttribute("sid"),this.name=e.getAttribute("name"),this.transforms=[],this.attachments=[];for(var t=0;t=0&&(n[u.KHR_MATERIALS_COMMON]=new a(c)),console.time("GLTFLoader");var d=new h(c,n,{path:r||this.path,crossOrigin:this.crossOrigin});d.parse(function(e,r,a,i){console.log("------------ UltimateLoader ---------------"),console.timeEnd("GLTFLoader");var s={scene:e,scenes:r,cameras:a,animations:i};t(s)})}},e.Shaders={update:function(){console.warn("THREE.GLTFLoader.Shaders has been deprecated, and now updates automatically.")}},r.prototype.update=function(e,t){var r=this.boundUniforms;for(var a in r){var i=r[a];switch(i.semantic){case"MODELVIEW":var s=i.uniform.value;s.multiplyMatrices(t.matrixWorldInverse,i.sourceNode.matrixWorld);break;case"MODELVIEWINVERSETRANSPOSE":var n=i.uniform.value;this._m4.multiplyMatrices(t.matrixWorldInverse,i.sourceNode.matrixWorld),n.getNormalMatrix(this._m4);break;case"PROJECTION":var s=i.uniform.value;s.copy(t.projectionMatrix);break;case"JOINTMATRIX":for(var o=i.uniform.value,l=0;l0?new Uint8Array(g.buffer,T,e):new Uint8Array);return T+=Uint8Array.BYTES_PER_ELEMENT*e,t}function n(e){if(T%Uint16Array.BYTES_PER_ELEMENT===0){var t=new Uint16Array(g.buffer,T,e);return T+=Uint16Array.BYTES_PER_ELEMENT*e,t}for(var t=new Uint16Array(e),r=0;r0?THREE.SmoothShading:THREE.FlatShading,this.debug&&console.log("Group Material",$,C)}var ee=new THREE.Mesh(Q,C);W&&(ee.name=W),P.add(ee)}}}}return this.performanceTimer&&console.timeEnd("BOMLoader"),y}},THREE.BOMLoaderUtil=THREE.BOMLoaderUtil||{},THREE.BOMLoaderUtil.multiload=function(e,t){function r(e,r){var s=new THREE.BOMLoader;s.setTexturePath(r.url.split("/").slice(0,-1).join("/")+"/"),void 0!==r.debug&&s.setDebug(r.debug),void 0!==r.timer&&s.setPerfTimer(r.timer),void 0!==r.crossOrigin&&s.setCrossOrigin(r.crossOrigin),void 0!==r.responseType&&s.setResponseType(r.responseType),s.load(r.url,function(s){r.object=s,i[e]=r,--a<=0&&t(i)})}e=e.constructor===Array?e:[e];for(var a=e.length,i=[],s=0;s Date: Mon, 8 May 2017 21:49:20 +0100 Subject: [PATCH 2/2] Fixed base path for BOMLoader. --- dist/UltimateLoader.js | 1 + dist/UltimateLoader.min.js | 6 +++--- dist/UltimateLoader2.js | 1 + dist/UltimateLoader2.min.js | 6 +++--- src/UltimateLoader.js | 1 + src/UltimateLoader2.js | 1 + 6 files changed, 10 insertions(+), 6 deletions(-) diff --git a/dist/UltimateLoader.js b/dist/UltimateLoader.js index cd68b57..4d158f2 100644 --- a/dist/UltimateLoader.js +++ b/dist/UltimateLoader.js @@ -309,6 +309,7 @@ var UltimateLoader = UltimateLoader || {}; var bomLoader = new THREE.BOMLoader(); + bomLoader.setPath(file.baseUrl); bomLoader.setTexturePath(file.baseUrl); bomLoader.setCrossOrigin(crossOrigin); diff --git a/dist/UltimateLoader.min.js b/dist/UltimateLoader.min.js index e9e41fc..7f765f7 100644 --- a/dist/UltimateLoader.min.js +++ b/dist/UltimateLoader.min.js @@ -1,3 +1,3 @@ -var UltimateLoader=UltimateLoader||{};!function(e){"use strict";function t(e,t,r){E.push([e,t,r])}function r(){if(v>E.length-1)return E=[],void(v=0);var e=E[v];v++,a(e[0],e[1],e[2])}function i(){0==v&&r()}function a(e,t,i){var a=s(n(e));switch(a.url=e,a.callback=t,null!=i&&(a.i=i),a.ext){case"obj":o(a);break;case"json":h(a);break;case"dae":c(a);break;case"gltf":d(a);break;case"glb":d(a);break;case"fbx":loadFBX(a);break;case"drc":loadDRACO(a);break;case"png":u(a);break;case"jpg":u(a);break;case"jpeg":u(a);break;case"bom":l(a);break;default:console.log("UltimateLoader: File extension -"+a.ext+"- not recognized! Object -"+a.name+"- did not load."),r()}}function s(e){var t=e.slice(0,e.lastIndexOf("/")+1),r=e.substr(e.lastIndexOf("/")+1),i=r.split("."),a=i[0],s=i[i.length-1].toLowerCase(),n={name:a,ext:s,baseUrl:t};return n}function n(e,t){if("string"!=typeof e||""===e)return"";if(/^(https?:)?\/\//i.test(e))return e;if(/^data:.*,.*$/i.test(e))return e;var r=new URL((t||"")+e,location.href.substring(0,location.href.lastIndexOf("/")+1));return r.toString()}function o(e){var t=e.name+".obj",r=e.name+".mtl",i=new THREE.MTLLoader;i.setPath(e.baseUrl),i.setTexturePath?i.setTexturePath(e.baseUrl):i.setBaseUrl(e.baseUrl),i.setCrossOrigin(g),i.load(r,function(r){r.preload();var i=new THREE.OBJLoader;i.setMaterials(r),i.setPath(e.baseUrl),i.load(t,function(t){e.object=t,m(e)},p,f)})}function l(e){var t=e.name+".bom",r=new THREE.BOMLoader;r.setTexturePath(e.baseUrl),r.setCrossOrigin(g),r.load(t,function(t){e.object=t,m(e)},p,f)}function h(e){var t=new THREE.ObjectLoader;t.load(e.url,function(t){e.object=t,m(e)},p,f)}function c(e){var t=new THREE.ColladaLoader;t.load(e.url,function(t){var r=t.scene;e.object=r,m(e)},p,f)}function u(t){var r=new THREE.TextureLoader;r.load(t.url,function(r){var i=r;if(e.loadImagesOnPlane){var a=r.image.naturalHeight/r.image.naturalWidth*e.imageSize,s=new THREE.PlaneGeometry(e.imageSize,a,e.imageSize),n=new THREE.MeshBasicMaterial({map:r,side:THREE.DoubleSide}),o=new THREE.Mesh(s,n);i=o}t.object=i,m(t)},p,f)}function d(e){var t=new THREE.GLTFLoader;t.load(e.url,function(t){var r=t.scene;e.object=r,m(e)},p,f)}function p(e){}function f(e){console.log("There was an error loading your object")}function m(t){null!=t.i?t.callback(t):t.callback(t.object),e.useQueue&&r(),console.log("UltimateLoader: Object "+t.name+" loaded!")}var E=[],v=0,g="anonymous";e.useQueue=!1,e.imageSize=32,e.loadImagesOnPlane=!1,e.load=function(r,s){e.useQueue?(t(r,s),i()):a(r,s)},e.multiload=function(r,s){console.time("Time");for(var n=[],o=0,l=function(e){n[e.i]=e.object,o++,o==r.length&&(s(n),console.timeEnd("Time"))},h=0;h=0?n.substring(0,o):n;l=l.toLowerCase();var h=o>=0?n.substring(o+1):"";if(h=h.trim(),"newmtl"===l)r={name:h},a[h]=r;else if(r)if("ka"===l||"kd"===l||"ks"===l){var c=h.split(i,3);r[l]=[parseFloat(c[0]),parseFloat(c[1]),parseFloat(c[2])]}else r[l]=h}}var u=new THREE.MTLLoader.MaterialCreator(this.texturePath||this.path,this.materialOptions);return u.setCrossOrigin(this.crossOrigin),u.setManager(this.manager),u.setMaterials(a),u}},THREE.MTLLoader.MaterialCreator=function(e,t){this.baseUrl=e||"",this.options=t,this.materialsInfo={},this.materials={},this.materialsArray=[],this.nameLookup={},this.side=this.options&&this.options.side?this.options.side:THREE.FrontSide,this.wrap=this.options&&this.options.wrap?this.options.wrap:THREE.RepeatWrapping},THREE.MTLLoader.MaterialCreator.prototype={constructor:THREE.MTLLoader.MaterialCreator,setCrossOrigin:function(e){this.crossOrigin=e},setManager:function(e){this.manager=e},setMaterials:function(e){this.materialsInfo=this.convert(e),this.materials={},this.materialsArray=[],this.nameLookup={}},convert:function(e){if(!this.options)return e;var t={};for(var r in e){var i=e[r],a={};t[r]=a;for(var s in i){var n=!0,o=i[s],l=s.toLowerCase();switch(l){case"kd":case"ka":case"ks":this.options&&this.options.normalizeRGB&&(o=[o[0]/255,o[1]/255,o[2]/255]),this.options&&this.options.ignoreZeroRGBs&&0===o[0]&&0===o[1]&&0===o[2]&&(n=!1)}n&&(a[l]=o)}}return t},preload:function(){for(var e in this.materialsInfo)this.create(e)},getIndex:function(e){return this.nameLookup[e]},getAsArray:function(){var e=0;for(var t in this.materialsInfo)this.materialsArray[e]=this.create(t),this.nameLookup[t]=e,e++;return this.materialsArray},create:function(e){return void 0===this.materials[e]&&this.createMaterial_(e),this.materials[e]},createMaterial_:function(e){function t(e,t){return"string"!=typeof t||""===t?"":/^https?:\/\//i.test(t)?t:e+t}function r(e,r){if(!s[e]){var a=i.getTextureParams(r,s),n=i.loadTexture(t(i.baseUrl,a.url));n.repeat.copy(a.scale),n.offset.copy(a.offset),n.wrapS=i.wrap,n.wrapT=i.wrap,s[e]=n}}var i=this,a=this.materialsInfo[e],s={name:e,side:this.side};for(var n in a){var o=a[n];if(""!==o)switch(n.toLowerCase()){case"kd":s.color=(new THREE.Color).fromArray(o);break;case"ks":s.specular=(new THREE.Color).fromArray(o);break;case"map_kd":r("map",o);break;case"map_ks":r("specularMap",o);break;case"map_bump":case"bump":r("bumpMap",o);break;case"ns":s.shininess=parseFloat(o);break;case"d":o<1&&(s.opacity=o,s.transparent=!0);break;case"Tr":o>0&&(s.opacity=1-o,s.transparent=!0)}}return this.materials[e]=new THREE.MeshPhongMaterial(s),this.materials[e]},getTextureParams:function(e,t){var r,i={scale:new THREE.Vector2(1,1),offset:new THREE.Vector2(0,0)},a=e.split(/\s+/);return r=a.indexOf("-bm"),r>=0&&(t.bumpScale=parseFloat(a[r+1]),a.splice(r,2)),r=a.indexOf("-s"),r>=0&&(i.scale.set(parseFloat(a[r+1]),parseFloat(a[r+2])),a.splice(r,4)),r=a.indexOf("-o"),r>=0&&(i.offset.set(parseFloat(a[r+1]),parseFloat(a[r+2])),a.splice(r,4)),i.url=a.join(" ").trim(),i},loadTexture:function(e,t,r,i,a){var s;if(altspace&&altspace.inClient)s=new THREE.Texture({src:e});else{var n=THREE.Loader.Handlers.get(e),o=void 0!==this.manager?this.manager:THREE.DefaultLoadingManager;null===n&&(n=new THREE.TextureLoader(o)),n.setCrossOrigin&&n.setCrossOrigin(this.crossOrigin),s=n.load(e,r,i,a)}return void 0!==t&&(s.mapping=t),s}},THREE.OBJLoader=function(e){this.manager=void 0!==e?e:THREE.DefaultLoadingManager,this.materials=null,this.regexp={vertex_pattern:/^v\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,normal_pattern:/^vn\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,uv_pattern:/^vt\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,face_vertex:/^f\s+(-?\d+)\s+(-?\d+)\s+(-?\d+)(?:\s+(-?\d+))?/,face_vertex_uv:/^f\s+(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)(?:\s+(-?\d+)\/(-?\d+))?/,face_vertex_uv_normal:/^f\s+(-?\d+)\/(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\/(-?\d+)(?:\s+(-?\d+)\/(-?\d+)\/(-?\d+))?/,face_vertex_normal:/^f\s+(-?\d+)\/\/(-?\d+)\s+(-?\d+)\/\/(-?\d+)\s+(-?\d+)\/\/(-?\d+)(?:\s+(-?\d+)\/\/(-?\d+))?/,object_pattern:/^[og]\s*(.+)?/,smoothing_pattern:/^s\s+(\d+|on|off)/,material_library_pattern:/^mtllib /,material_use_pattern:/^usemtl /}},THREE.OBJLoader.prototype={constructor:THREE.OBJLoader,load:function(e,t,r,i){var a=this,s=new THREE.FileLoader(a.manager);s.setPath(this.path),s.load(e,function(e){t(a.parse(e))},r,i)},setPath:function(e){this.path=e},setMaterials:function(e){this.materials=e},_createParserState:function(){var e={objects:[],object:{},vertices:[],normals:[],uvs:[],materialLibraries:[],startObject:function(e,t){if(this.object&&this.object.fromDeclaration===!1)return this.object.name=e,void(this.object.fromDeclaration=t!==!1);var r=this.object&&"function"==typeof this.object.currentMaterial?this.object.currentMaterial():void 0;if(this.object&&"function"==typeof this.object._finalize&&this.object._finalize(!0),this.object={name:e||"",fromDeclaration:t!==!1,geometry:{vertices:[],normals:[],uvs:[]},materials:[],smooth:!0,startMaterial:function(e,t){var r=this._finalize(!1);r&&(r.inherited||r.groupCount<=0)&&this.materials.splice(r.index,1);var i={index:this.materials.length,name:e||"",mtllib:Array.isArray(t)&&t.length>0?t[t.length-1]:"",smooth:void 0!==r?r.smooth:this.smooth,groupStart:void 0!==r?r.groupEnd:0,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(e){var t={index:"number"==typeof e?e:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return t.clone=this.clone.bind(t),t}};return this.materials.push(i),i},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(e){var t=this.currentMaterial();if(t&&t.groupEnd===-1&&(t.groupEnd=this.geometry.vertices.length/3,t.groupCount=t.groupEnd-t.groupStart,t.inherited=!1),e&&this.materials.length>1)for(var r=this.materials.length-1;r>=0;r--)this.materials[r].groupCount<=0&&this.materials.splice(r,1);return e&&0===this.materials.length&&this.materials.push({name:"",smooth:this.smooth}),t}},r&&r.name&&"function"==typeof r.clone){var i=r.clone(0);i.inherited=!0,this.object.materials.push(i)}this.objects.push(this.object)},finalize:function(){this.object&&"function"==typeof this.object._finalize&&this.object._finalize(!0)},parseVertexIndex:function(e,t){var r=parseInt(e,10);return 3*(r>=0?r-1:r+t/3)},parseNormalIndex:function(e,t){var r=parseInt(e,10);return 3*(r>=0?r-1:r+t/3)},parseUVIndex:function(e,t){var r=parseInt(e,10);return 2*(r>=0?r-1:r+t/2)},addVertex:function(e,t,r){var i=this.vertices,a=this.object.geometry.vertices;a.push(i[e+0]),a.push(i[e+1]),a.push(i[e+2]),a.push(i[t+0]),a.push(i[t+1]),a.push(i[t+2]),a.push(i[r+0]),a.push(i[r+1]),a.push(i[r+2])},addVertexLine:function(e){var t=this.vertices,r=this.object.geometry.vertices;r.push(t[e+0]),r.push(t[e+1]),r.push(t[e+2])},addNormal:function(e,t,r){var i=this.normals,a=this.object.geometry.normals;a.push(i[e+0]),a.push(i[e+1]),a.push(i[e+2]),a.push(i[t+0]),a.push(i[t+1]),a.push(i[t+2]),a.push(i[r+0]),a.push(i[r+1]),a.push(i[r+2])},addUV:function(e,t,r){var i=this.uvs,a=this.object.geometry.uvs;a.push(i[e+0]),a.push(i[e+1]),a.push(i[t+0]),a.push(i[t+1]),a.push(i[r+0]),a.push(i[r+1])},addUVLine:function(e){var t=this.uvs,r=this.object.geometry.uvs;r.push(t[e+0]),r.push(t[e+1])},addFace:function(e,t,r,i,a,s,n,o,l,h,c,u){var d,p=this.vertices.length,f=this.parseVertexIndex(e,p),m=this.parseVertexIndex(t,p),E=this.parseVertexIndex(r,p);if(void 0===i?this.addVertex(f,m,E):(d=this.parseVertexIndex(i,p),this.addVertex(f,m,d),this.addVertex(m,E,d)),void 0!==a){var v=this.uvs.length;f=this.parseUVIndex(a,v),m=this.parseUVIndex(s,v),E=this.parseUVIndex(n,v),void 0===i?this.addUV(f,m,E):(d=this.parseUVIndex(o,v),this.addUV(f,m,d),this.addUV(m,E,d))}if(void 0!==l){var g=this.normals.length;f=this.parseNormalIndex(l,g),m=l===h?f:this.parseNormalIndex(h,g),E=l===c?f:this.parseNormalIndex(c,g),void 0===i?this.addNormal(f,m,E):(d=this.parseNormalIndex(u,g),this.addNormal(f,m,d),this.addNormal(m,E,d))}},addLineGeometry:function(e,t){this.object.geometry.type="Line";for(var r=this.vertices.length,i=this.uvs.length,a=0,s=e.length;a0?A.addAttribute("normal",new THREE.BufferAttribute(new Float32Array(R.normals),3)):A.computeVertexNormals(),R.uvs.length>0&&A.addAttribute("uv",new THREE.BufferAttribute(new Float32Array(R.uvs),2));for(var N=[],M=0,H=w.length;M1){for(var M=0,H=w.length;M0?t:"visual_scene0"]}return null}function n(){var e=je.querySelectorAll("instance_kinematics_model")[0];if(e){var t=e.getAttribute("url").replace(/^#/,"");return Oe[t.length>0?t:"kinematics_model0"]}return null}function o(){_e=[],l(Pe)}function l(e){var t=He.getChildById(e.colladaId,!0),r=null;if(t&&t.keys){r={fps:60,hierarchy:[{node:t,keys:t.keys,sids:t.sids}],node:e,name:"animation_"+e.name,length:0},_e.push(r);for(var i=0,a=t.keys.length;i=0){var n=t.invBindMatrices[a];i.invBindMatrix=n,i.skinningMatrix=new THREE.Matrix4,i.skinningMatrix.multiplyMatrices(i.world,n),i.animatrix=new THREE.Matrix4,i.animatrix.copy(i.localworld),i.weights=[];for(var s=0;ss.limits.max||r1)for(L=new THREE.MultiMaterial(b),s=0;s<_.faces.length;s++){var S=_.faces[s];S.materialIndex=T[S.daeMaterial]}void 0!==r?(m(_,r),_.morphTargets.length>0?(L.morphTargets=!0,L.skinning=!1):(L.morphTargets=!1,L.skinning=!0),H=new THREE.SkinnedMesh(_,L,!1),H.name="skin_"+Fe.length,Fe.push(H)):void 0!==i?(c(_,i),L.morphTargets=!0,H=new THREE.Mesh(_,L),H.name="morph_"+Ie.length,Ie.push(H)):H=_.isLineStrip===!0?new THREE.Line(_):new THREE.Mesh(_,L),n.add(H)}}for(a=0;at)break}return r}function R(e,t){for(var r=-1,i=0,a=e.length;i=t&&(r=i)}return r}function w(e,t,r,i){var a=A(e,i,r?r-1:0),s=x(e,i,r+1);if(a&&s){var n,o=(t.time-a.time)/(s.time-a.time),l=a.getTarget(i),h=s.getTarget(i).data,c=l.data;if("matrix"===l.type)n=c;else if(c.length){n=[];for(var u=0;u=0?r:r+e.length;r>=0;r--){var i=e[r];if(i.hasTarget(t))return i}return null}function N(){this.id="",this.init_from=""}function M(){this.id="",this.name="",this.type="",this.skin=null,this.morph=null}function H(){this.method=null,this.source=null,this.targets=null,this.weights=null}function L(){this.source="",this.bindShapeMatrix=null,this.invBindMatrices=[],this.joints=[],this.weights=[]}function _(){this.id="",this.name="",this.nodes=[],this.scene=new THREE.Group}function S(){this.id="",this.name="",this.sid="",this.nodes=[],this.controllers=[],this.transforms=[],this.geometries=[],this.channels=[],this.matrix=new THREE.Matrix4}function k(){this.sid="",this.type="",this.data=[],this.obj=null}function O(){this.url="",this.skeleton=[],this.instance_material=[]}function C(){this.symbol="",this.target=""}function I(){this.url="",this.instance_material=[]}function F(){this.id="",this.mesh=null}function j(e){this.geometry=e.id,this.primitives=[],this.vertices=null,this.geometry3js=null}function P(){this.material="",this.count=0,this.inputs=[],this.vcount=null,this.p=[],this.geometry=new THREE.Geometry}function U(){P.call(this),this.vcount=[]}function B(){P.call(this),this.vcount=1}function D(){P.call(this),this.vcount=3}function V(){this.source="",this.count=0,this.stride=0,this.params=[]}function G(){this.input={}}function Y(){this.semantic="",this.offset=0,this.source="",this.set=0}function q(e){this.id=e,this.type=null}function X(){this.id="",this.name="",this.instance_effect=null}function z(){this.color=new THREE.Color,this.color.setRGB(Math.random(),Math.random(),Math.random()),this.color.a=1,this.texture=null,this.texcoord=null,this.texOpts=null}function W(e,t){this.type=e,this.effect=t,this.material=null}function Z(e){this.effect=e,this.init_from=null,this.format=null}function K(e){this.effect=e,this.source=null,this.wrap_s=null,this.wrap_t=null,this.minfilter=null,this.magfilter=null,this.mipfilter=null}function J(){this.id="",this.name="",this.shader=null,this.surface={},this.sampler={}}function Q(){this.url=""}function $(){this.id="",this.name="",this.source={},this.sampler=[],this.channel=[]}function ee(e){this.animation=e,this.source="",this.target="",this.fullSid=null,this.sid=null,this.dotSyntax=null,this.arrSyntax=null,this.arrIndices=null,this.member=null}function te(e){this.id="",this.animation=e,this.inputs=[],this.input=null,this.output=null,this.strideOut=null,this.interpolation=null,this.startTime=null,this.endTime=null,this.duration=0}function re(e){this.targets=[],this.time=e}function ie(){this.id="",this.name="",this.technique=""}function ae(){this.url=""}function se(){this.id="",this.name="",this.technique=""}function ne(){this.url=""; -}function oe(){this.id="",this.name="",this.joints=[],this.links=[]}function le(){this.sid="",this.name="",this.axis=new THREE.Vector3,this.limits={min:0,max:0},this.type="",this.static=!1,this.zeroPosition=0,this.middlePosition=0}function he(){this.sid="",this.name="",this.transforms=[],this.attachments=[]}function ce(){this.joint="",this.transforms=[],this.links=[]}function ue(e){var t=e.getAttribute("id");return void 0!=Be[t]?Be[t]:(Be[t]=new q(t).parse(e),Be[t])}function de(e){for(var t=me(e),r=[],i=0,a=t.length;i0?Ee(e).split(/\s+/):[]}function Ee(e){return e.replace(/^\s+/,"").replace(/\s+$/,"")}function ve(e,t,r){return e.hasAttribute(t)?parseInt(e.getAttribute(t),10):r}function ge(e,t){if("string"!=typeof e||""===e)return"";if(/^(https?:)?\/\//i.test(e))return e;if(/^data:.*,.*$/i.test(e))return e;var r=new URL((t||"")+e,location.href.substring(0,location.href.lastIndexOf("/")+1));return r.toString()}function Te(e,t){var r=new THREE.ImageLoader;r.load(t,function(t){e.image=t,e.needsUpdate=!0})}function be(e,t){e.doubleSided=!1;var r=t.querySelectorAll("extra double_sided")[0];r&&r&&1===parseInt(r.textContent,10)&&(e.doubleSided=!0)}function ye(){if(Ke.convertUpAxis!==!0||Qe===Ke.upAxis)$e=null;else switch(Qe){case"X":$e="Y"===Ke.upAxis?"XtoY":"XtoZ";break;case"Y":$e="X"===Ke.upAxis?"YtoX":"YtoZ";break;case"Z":$e="X"===Ke.upAxis?"ZtoX":"ZtoY"}}function Re(e,t){if(Ke.convertUpAxis===!0&&Qe!==Ke.upAxis)switch($e){case"XtoY":var r=e[0];e[0]=t*e[1],e[1]=r;break;case"XtoZ":var r=e[2];e[2]=e[1],e[1]=e[0],e[0]=r;break;case"YtoX":var r=e[0];e[0]=e[1],e[1]=t*r;break;case"YtoZ":var r=e[1];e[1]=t*e[2],e[2]=r;break;case"ZtoX":var r=e[0];e[0]=e[1],e[1]=e[2],e[2]=r;break;case"ZtoY":var r=e[1];e[1]=e[2],e[2]=t*r}}function we(e,t){if(Ke.convertUpAxis!==!0||Qe===Ke.upAxis)return t;switch(e){case"X":t="XtoY"===$e?t*-1:t;break;case"Y":t="YtoZ"===$e||"YtoX"===$e?t*-1:t;break;case"Z":t="ZtoY"===$e?t*-1:t}return t}function xe(e,t){var r=[e[t],e[t+1],e[t+2]];return Re(r,-1),new THREE.Vector3(r[0],r[1],r[2])}function Ae(e){if(Ke.convertUpAxis){var t=[e[0],e[4],e[8]];Re(t,-1),e[0]=t[0],e[4]=t[1],e[8]=t[2],t=[e[1],e[5],e[9]],Re(t,-1),e[1]=t[0],e[5]=t[1],e[9]=t[2],t=[e[2],e[6],e[10]],Re(t,-1),e[2]=t[0],e[6]=t[1],e[10]=t[2],t=[e[0],e[1],e[2]],Re(t,-1),e[0]=t[0],e[1]=t[1],e[2]=t[2],t=[e[4],e[5],e[6]],Re(t,-1),e[4]=t[0],e[5]=t[1],e[6]=t[2],t=[e[8],e[9],e[10]],Re(t,-1),e[8]=t[0],e[9]=t[1],e[10]=t[2],t=[e[3],e[7],e[11]],Re(t,-1),e[3]=t[0],e[7]=t[1],e[11]=t[2]}return(new THREE.Matrix4).set(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15])}function Ne(e){if(e>-1&&e<3){var t=["X","Y","Z"],r={X:0,Y:1,Z:2};e=Me(t[e]),e=r[e]}return e}function Me(e){if(Ke.convertUpAxis)switch(e){case"X":switch($e){case"XtoY":case"XtoZ":case"YtoX":e="Y";break;case"ZtoX":e="Z"}break;case"Y":switch($e){case"XtoY":case"YtoX":case"ZtoX":e="X";break;case"XtoZ":case"YtoZ":case"ZtoY":e="Z"}break;case"Z":switch($e){case"XtoZ":e="X";break;case"YtoZ":case"ZtoX":case"ZtoY":e="Y"}}return e}var He,Le,_e,Se,ke,Oe,Ce,Ie,Fe,je=null,Pe=null,Ue=null,Be={},De={},Ve={},Ge={},Ye={},qe={},Xe={},ze={},We={},Ze=THREE.SmoothShading,Ke={centerGeometry:!1,convertUpAxis:!1,subdivideFaces:!0,upAxis:"Y",defaultEnvMap:null},Je=1,Qe="Y",$e=null;return N.prototype.parse=function(e){this.id=e.getAttribute("id");for(var t=0;t=0,l=n.indexOf("(")>=0;if(o)s=n.split("."),n=s.shift(),i=s.shift();else if(l){r=n.split("("),n=r.shift();for(var h=0;h4&&Ke.subdivideFaces){var L=R.length?R:new THREE.Color;for(i=1;i4?[A[0],A[w+1],A[w+2]]:4===d?0===w?[A[0],A[1],A[3]]:[A[1].clone(),A[2],A[3].clone()]:[A[0],A[1],A[2]],void 0===t.faceVertexUvs[i]&&(t.faceVertexUvs[i]=[]),t.faceVertexUvs[i].push(N);else console.log("dropped face with vcount "+d+" for geometry with id: "+t.id);g+=p*d}},P.prototype.setVertices=function(e){for(var t=0;t0&&(this[r.nodeName]=parseFloat(a[0].textContent))}}return this.create(),this},W.prototype.create=function(){var e={},t=!1;if(void 0!==this.transparency&&void 0!==this.transparent){var r=(this.transparent,(this.transparent.color.r+this.transparent.color.g+this.transparent.color.b)/3*this.transparency);r>0&&(t=!0,e.transparent=!0,e.opacity=1-r)}var i={diffuse:"map",ambient:"lightMap",specular:"specularMap",emission:"emissionMap",bump:"bumpMap",normal:"normalMap"};for(var a in this)switch(a){case"ambient":case"emission":case"diffuse":case"specular":case"bump":case"normal":var s=this[a];if(s instanceof z)if(s.isTexture()){var n=s.texture,o=this.effect.sampler[n];if(void 0!==o&&void 0!==o.source){var l=this.effect.surface[o.source];if(void 0!==l){var h=De[l.init_from];if(h){var c,u=Ce+h.init_from;if(altspace&&altspace.inClient)c=new THREE.Texture({src:ge(u)});else{var d=THREE.Loader.Handlers.get(u);null!==d?c=d.load(u):(c=new THREE.Texture,Te(c,u))}"MIRROR"===o.wrap_s?c.wrapS=THREE.MirroredRepeatWrapping:"WRAP"===o.wrap_s||s.texOpts.wrapU?c.wrapS=THREE.RepeatWrapping:c.wrapS=THREE.ClampToEdgeWrapping,"MIRROR"===o.wrap_t?c.wrapT=THREE.MirroredRepeatWrapping:"WRAP"===o.wrap_t||s.texOpts.wrapV?c.wrapT=THREE.RepeatWrapping:c.wrapT=THREE.ClampToEdgeWrapping,c.offset.x=s.texOpts.offsetU,c.offset.y=s.texOpts.offsetV,c.repeat.x=s.texOpts.repeatU,c.repeat.y=s.texOpts.repeatV,e[i[a]]=c,"emission"===a&&(e.emissive=16777215)}}}}else"diffuse"!==a&&t||("emission"===a?e.emissive=s.color.getHex():e[a]=s.color.getHex());break;case"shininess":e[a]=this[a];break;case"reflectivity":e[a]=this[a],e[a]>0&&(e.envMap=Ke.defaultEnvMap),e.combine=THREE.MixOperation;break;case"index_of_refraction":e.refractionRatio=this[a],1!==this[a]&&(e.envMap=Ke.defaultEnvMap);break;case"transparency":}switch(e.shading=Ze,e.side=this.effect.doubleSided?THREE.DoubleSide:THREE.FrontSide,void 0!==e.diffuse&&(e.color=e.diffuse,delete e.diffuse),this.type){case"constant":void 0!=e.emissive&&(e.color=e.emissive),this.material=new THREE.MeshBasicMaterial(e);break;case"phong":case"blinn":this.material=new THREE.MeshPhongMaterial(e);break;case"lambert":default:this.material=new THREE.MeshLambertMaterial(e)}return this.material},Z.prototype.parse=function(e){for(var t=0;t=0,a=r.indexOf("(")>=0;if(i)t=r.split("."),this.sid=t.shift(),this.member=t.shift();else if(a){var s=r.split("(");this.sid=s.shift();for(var n=0;n1){i=[],t*=this.strideOut;for(var a=0;a1&&(o=1),h.length){a=[];for(var c=0;c=this.limits.max&&(this.static=!0), -this.middlePosition=(this.limits.min+this.limits.max)/2,this},he.prototype.parse=function(e){this.sid=e.getAttribute("sid"),this.name=e.getAttribute("name"),this.transforms=[],this.attachments=[];for(var t=0;t=0&&(n[u.KHR_MATERIALS_COMMON]=new i(h)),console.time("GLTFLoader");var d=new c(h,n,{path:r||this.path,crossOrigin:this.crossOrigin});d.parse(function(e,r,i,a){console.log("------------ UltimateLoader ---------------"),console.timeEnd("GLTFLoader");var s={scene:e,scenes:r,cameras:i,animations:a};t(s)})}},e.Shaders={update:function(){console.warn("THREE.GLTFLoader.Shaders has been deprecated, and now updates automatically.")}},r.prototype.update=function(e,t){var r=this.boundUniforms;for(var i in r){var a=r[i];switch(a.semantic){case"MODELVIEW":var s=a.uniform.value;s.multiplyMatrices(t.matrixWorldInverse,a.sourceNode.matrixWorld);break;case"MODELVIEWINVERSETRANSPOSE":var n=a.uniform.value;this._m4.multiplyMatrices(t.matrixWorldInverse,a.sourceNode.matrixWorld),n.getNormalMatrix(this._m4);break;case"PROJECTION":var s=a.uniform.value;s.copy(t.projectionMatrix);break;case"JOINTMATRIX":for(var o=a.uniform.value,l=0;l0?new Uint8Array(g.buffer,T,e):new Uint8Array);return T+=Uint8Array.BYTES_PER_ELEMENT*e,t}function n(e){if(T%Uint16Array.BYTES_PER_ELEMENT===0){var t=new Uint16Array(g.buffer,T,e);return T+=Uint16Array.BYTES_PER_ELEMENT*e,t}for(var t=new Uint16Array(e),r=0;r0?THREE.SmoothShading:THREE.FlatShading,this.debug&&console.log("Group Material",$,C)}var ee=new THREE.Mesh(Q,C);W&&(ee.name=W),P.add(ee)}}}}return this.performanceTimer&&console.timeEnd("BOMLoader"),y}},THREE.BOMLoaderUtil=THREE.BOMLoaderUtil||{},THREE.BOMLoaderUtil.multiload=function(e,t){function r(e,r){var s=new THREE.BOMLoader;s.setTexturePath(r.url.split("/").slice(0,-1).join("/")+"/"),void 0!==r.debug&&s.setDebug(r.debug),void 0!==r.timer&&s.setPerfTimer(r.timer),void 0!==r.crossOrigin&&s.setCrossOrigin(r.crossOrigin),void 0!==r.responseType&&s.setResponseType(r.responseType),s.load(r.url,function(s){r.object=s,a[e]=r,--i<=0&&t(a)})}e=e.constructor===Array?e:[e];for(var i=e.length,a=[],s=0;sE.length-1)return E=[],void(v=0);var e=E[v];v++,i(e[0],e[1],e[2])}function a(){0==v&&r()}function i(e,t,a){var i=s(n(e));switch(i.url=e,i.callback=t,null!=a&&(i.i=a),i.ext){case"obj":o(i);break;case"json":h(i);break;case"dae":c(i);break;case"gltf":d(i);break;case"glb":d(i);break;case"fbx":loadFBX(i);break;case"drc":loadDRACO(i);break;case"png":u(i);break;case"jpg":u(i);break;case"jpeg":u(i);break;case"bom":l(i);break;default:console.log("UltimateLoader: File extension -"+i.ext+"- not recognized! Object -"+i.name+"- did not load."),r()}}function s(e){var t=e.slice(0,e.lastIndexOf("/")+1),r=e.substr(e.lastIndexOf("/")+1),a=r.split("."),i=a[0],s=a[a.length-1].toLowerCase(),n={name:i,ext:s,baseUrl:t};return n}function n(e,t){if("string"!=typeof e||""===e)return"";if(/^(https?:)?\/\//i.test(e))return e;if(/^data:.*,.*$/i.test(e))return e;var r=new URL((t||"")+e,location.href.substring(0,location.href.lastIndexOf("/")+1));return r.toString()}function o(e){var t=e.name+".obj",r=e.name+".mtl",a=new THREE.MTLLoader;a.setPath(e.baseUrl),a.setTexturePath?a.setTexturePath(e.baseUrl):a.setBaseUrl(e.baseUrl),a.setCrossOrigin(g),a.load(r,function(r){r.preload();var a=new THREE.OBJLoader;a.setMaterials(r),a.setPath(e.baseUrl),a.load(t,function(t){e.object=t,m(e)},p,f)})}function l(e){var t=e.name+".bom",r=new THREE.BOMLoader;r.setPath(e.baseUrl),r.setTexturePath(e.baseUrl),r.setCrossOrigin(g),r.load(t,function(t){e.object=t,m(e)},p,f)}function h(e){var t=new THREE.ObjectLoader;t.load(e.url,function(t){e.object=t,m(e)},p,f)}function c(e){var t=new THREE.ColladaLoader;t.load(e.url,function(t){var r=t.scene;e.object=r,m(e)},p,f)}function u(t){var r=new THREE.TextureLoader;r.load(t.url,function(r){var a=r;if(e.loadImagesOnPlane){var i=r.image.naturalHeight/r.image.naturalWidth*e.imageSize,s=new THREE.PlaneGeometry(e.imageSize,i,e.imageSize),n=new THREE.MeshBasicMaterial({map:r,side:THREE.DoubleSide}),o=new THREE.Mesh(s,n);a=o}t.object=a,m(t)},p,f)}function d(e){var t=new THREE.GLTFLoader;t.load(e.url,function(t){var r=t.scene;e.object=r,m(e)},p,f)}function p(e){}function f(e){console.log("There was an error loading your object")}function m(t){null!=t.i?t.callback(t):t.callback(t.object),e.useQueue&&r(),console.log("UltimateLoader: Object "+t.name+" loaded!")}var E=[],v=0,g="anonymous";e.useQueue=!1,e.imageSize=32,e.loadImagesOnPlane=!1,e.load=function(r,s){e.useQueue?(t(r,s),a()):i(r,s)},e.multiload=function(r,s){console.time("Time");for(var n=[],o=0,l=function(e){n[e.i]=e.object,o++,o==r.length&&(s(n),console.timeEnd("Time"))},h=0;h=0?n.substring(0,o):n;l=l.toLowerCase();var h=o>=0?n.substring(o+1):"";if(h=h.trim(),"newmtl"===l)r={name:h},i[h]=r;else if(r)if("ka"===l||"kd"===l||"ks"===l){var c=h.split(a,3);r[l]=[parseFloat(c[0]),parseFloat(c[1]),parseFloat(c[2])]}else r[l]=h}}var u=new THREE.MTLLoader.MaterialCreator(this.texturePath||this.path,this.materialOptions);return u.setCrossOrigin(this.crossOrigin),u.setManager(this.manager),u.setMaterials(i),u}},THREE.MTLLoader.MaterialCreator=function(e,t){this.baseUrl=e||"",this.options=t,this.materialsInfo={},this.materials={},this.materialsArray=[],this.nameLookup={},this.side=this.options&&this.options.side?this.options.side:THREE.FrontSide,this.wrap=this.options&&this.options.wrap?this.options.wrap:THREE.RepeatWrapping},THREE.MTLLoader.MaterialCreator.prototype={constructor:THREE.MTLLoader.MaterialCreator,setCrossOrigin:function(e){this.crossOrigin=e},setManager:function(e){this.manager=e},setMaterials:function(e){this.materialsInfo=this.convert(e),this.materials={},this.materialsArray=[],this.nameLookup={}},convert:function(e){if(!this.options)return e;var t={};for(var r in e){var a=e[r],i={};t[r]=i;for(var s in a){var n=!0,o=a[s],l=s.toLowerCase();switch(l){case"kd":case"ka":case"ks":this.options&&this.options.normalizeRGB&&(o=[o[0]/255,o[1]/255,o[2]/255]),this.options&&this.options.ignoreZeroRGBs&&0===o[0]&&0===o[1]&&0===o[2]&&(n=!1)}n&&(i[l]=o)}}return t},preload:function(){for(var e in this.materialsInfo)this.create(e)},getIndex:function(e){return this.nameLookup[e]},getAsArray:function(){var e=0;for(var t in this.materialsInfo)this.materialsArray[e]=this.create(t),this.nameLookup[t]=e,e++;return this.materialsArray},create:function(e){return void 0===this.materials[e]&&this.createMaterial_(e),this.materials[e]},createMaterial_:function(e){function t(e,t){return"string"!=typeof t||""===t?"":/^https?:\/\//i.test(t)?t:e+t}function r(e,r){if(!s[e]){var i=a.getTextureParams(r,s),n=a.loadTexture(t(a.baseUrl,i.url));n.repeat.copy(i.scale),n.offset.copy(i.offset),n.wrapS=a.wrap,n.wrapT=a.wrap,s[e]=n}}var a=this,i=this.materialsInfo[e],s={name:e,side:this.side};for(var n in i){var o=i[n];if(""!==o)switch(n.toLowerCase()){case"kd":s.color=(new THREE.Color).fromArray(o);break;case"ks":s.specular=(new THREE.Color).fromArray(o);break;case"map_kd":r("map",o);break;case"map_ks":r("specularMap",o);break;case"map_bump":case"bump":r("bumpMap",o);break;case"ns":s.shininess=parseFloat(o);break;case"d":o<1&&(s.opacity=o,s.transparent=!0);break;case"Tr":o>0&&(s.opacity=1-o,s.transparent=!0)}}return this.materials[e]=new THREE.MeshPhongMaterial(s),this.materials[e]},getTextureParams:function(e,t){var r,a={scale:new THREE.Vector2(1,1),offset:new THREE.Vector2(0,0)},i=e.split(/\s+/);return r=i.indexOf("-bm"),r>=0&&(t.bumpScale=parseFloat(i[r+1]),i.splice(r,2)),r=i.indexOf("-s"),r>=0&&(a.scale.set(parseFloat(i[r+1]),parseFloat(i[r+2])),i.splice(r,4)),r=i.indexOf("-o"),r>=0&&(a.offset.set(parseFloat(i[r+1]),parseFloat(i[r+2])),i.splice(r,4)),a.url=i.join(" ").trim(),a},loadTexture:function(e,t,r,a,i){var s;if(altspace&&altspace.inClient)s=new THREE.Texture({src:e});else{var n=THREE.Loader.Handlers.get(e),o=void 0!==this.manager?this.manager:THREE.DefaultLoadingManager;null===n&&(n=new THREE.TextureLoader(o)),n.setCrossOrigin&&n.setCrossOrigin(this.crossOrigin),s=n.load(e,r,a,i)}return void 0!==t&&(s.mapping=t),s}},THREE.OBJLoader=function(e){this.manager=void 0!==e?e:THREE.DefaultLoadingManager,this.materials=null,this.regexp={vertex_pattern:/^v\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,normal_pattern:/^vn\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,uv_pattern:/^vt\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,face_vertex:/^f\s+(-?\d+)\s+(-?\d+)\s+(-?\d+)(?:\s+(-?\d+))?/,face_vertex_uv:/^f\s+(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)(?:\s+(-?\d+)\/(-?\d+))?/,face_vertex_uv_normal:/^f\s+(-?\d+)\/(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\/(-?\d+)(?:\s+(-?\d+)\/(-?\d+)\/(-?\d+))?/,face_vertex_normal:/^f\s+(-?\d+)\/\/(-?\d+)\s+(-?\d+)\/\/(-?\d+)\s+(-?\d+)\/\/(-?\d+)(?:\s+(-?\d+)\/\/(-?\d+))?/,object_pattern:/^[og]\s*(.+)?/,smoothing_pattern:/^s\s+(\d+|on|off)/,material_library_pattern:/^mtllib /,material_use_pattern:/^usemtl /}},THREE.OBJLoader.prototype={constructor:THREE.OBJLoader,load:function(e,t,r,a){var i=this,s=new THREE.FileLoader(i.manager);s.setPath(this.path),s.load(e,function(e){t(i.parse(e))},r,a)},setPath:function(e){this.path=e},setMaterials:function(e){this.materials=e},_createParserState:function(){var e={objects:[],object:{},vertices:[],normals:[],uvs:[],materialLibraries:[],startObject:function(e,t){if(this.object&&this.object.fromDeclaration===!1)return this.object.name=e,void(this.object.fromDeclaration=t!==!1);var r=this.object&&"function"==typeof this.object.currentMaterial?this.object.currentMaterial():void 0;if(this.object&&"function"==typeof this.object._finalize&&this.object._finalize(!0),this.object={name:e||"",fromDeclaration:t!==!1,geometry:{vertices:[],normals:[],uvs:[]},materials:[],smooth:!0,startMaterial:function(e,t){var r=this._finalize(!1);r&&(r.inherited||r.groupCount<=0)&&this.materials.splice(r.index,1);var a={index:this.materials.length,name:e||"",mtllib:Array.isArray(t)&&t.length>0?t[t.length-1]:"",smooth:void 0!==r?r.smooth:this.smooth,groupStart:void 0!==r?r.groupEnd:0,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(e){var t={index:"number"==typeof e?e:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return t.clone=this.clone.bind(t),t}};return this.materials.push(a),a},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(e){var t=this.currentMaterial();if(t&&t.groupEnd===-1&&(t.groupEnd=this.geometry.vertices.length/3,t.groupCount=t.groupEnd-t.groupStart,t.inherited=!1),e&&this.materials.length>1)for(var r=this.materials.length-1;r>=0;r--)this.materials[r].groupCount<=0&&this.materials.splice(r,1);return e&&0===this.materials.length&&this.materials.push({name:"",smooth:this.smooth}),t}},r&&r.name&&"function"==typeof r.clone){var a=r.clone(0);a.inherited=!0,this.object.materials.push(a)}this.objects.push(this.object)},finalize:function(){this.object&&"function"==typeof this.object._finalize&&this.object._finalize(!0)},parseVertexIndex:function(e,t){var r=parseInt(e,10);return 3*(r>=0?r-1:r+t/3)},parseNormalIndex:function(e,t){var r=parseInt(e,10);return 3*(r>=0?r-1:r+t/3)},parseUVIndex:function(e,t){var r=parseInt(e,10);return 2*(r>=0?r-1:r+t/2)},addVertex:function(e,t,r){var a=this.vertices,i=this.object.geometry.vertices;i.push(a[e+0]),i.push(a[e+1]),i.push(a[e+2]),i.push(a[t+0]),i.push(a[t+1]),i.push(a[t+2]),i.push(a[r+0]),i.push(a[r+1]),i.push(a[r+2])},addVertexLine:function(e){var t=this.vertices,r=this.object.geometry.vertices;r.push(t[e+0]),r.push(t[e+1]),r.push(t[e+2])},addNormal:function(e,t,r){var a=this.normals,i=this.object.geometry.normals;i.push(a[e+0]),i.push(a[e+1]),i.push(a[e+2]),i.push(a[t+0]),i.push(a[t+1]),i.push(a[t+2]),i.push(a[r+0]),i.push(a[r+1]),i.push(a[r+2])},addUV:function(e,t,r){var a=this.uvs,i=this.object.geometry.uvs;i.push(a[e+0]),i.push(a[e+1]),i.push(a[t+0]),i.push(a[t+1]),i.push(a[r+0]),i.push(a[r+1])},addUVLine:function(e){var t=this.uvs,r=this.object.geometry.uvs;r.push(t[e+0]),r.push(t[e+1])},addFace:function(e,t,r,a,i,s,n,o,l,h,c,u){var d,p=this.vertices.length,f=this.parseVertexIndex(e,p),m=this.parseVertexIndex(t,p),E=this.parseVertexIndex(r,p);if(void 0===a?this.addVertex(f,m,E):(d=this.parseVertexIndex(a,p),this.addVertex(f,m,d),this.addVertex(m,E,d)),void 0!==i){var v=this.uvs.length;f=this.parseUVIndex(i,v),m=this.parseUVIndex(s,v),E=this.parseUVIndex(n,v),void 0===a?this.addUV(f,m,E):(d=this.parseUVIndex(o,v),this.addUV(f,m,d),this.addUV(m,E,d))}if(void 0!==l){var g=this.normals.length;f=this.parseNormalIndex(l,g),m=l===h?f:this.parseNormalIndex(h,g),E=l===c?f:this.parseNormalIndex(c,g),void 0===a?this.addNormal(f,m,E):(d=this.parseNormalIndex(u,g),this.addNormal(f,m,d),this.addNormal(m,E,d))}},addLineGeometry:function(e,t){this.object.geometry.type="Line";for(var r=this.vertices.length,a=this.uvs.length,i=0,s=e.length;i0?A.addAttribute("normal",new THREE.BufferAttribute(new Float32Array(R.normals),3)):A.computeVertexNormals(),R.uvs.length>0&&A.addAttribute("uv",new THREE.BufferAttribute(new Float32Array(R.uvs),2));for(var N=[],M=0,H=w.length;M1){for(var M=0,H=w.length;M0?t:"visual_scene0"]}return null}function n(){var e=je.querySelectorAll("instance_kinematics_model")[0];if(e){var t=e.getAttribute("url").replace(/^#/,"");return Oe[t.length>0?t:"kinematics_model0"]}return null}function o(){_e=[],l(Pe)}function l(e){var t=He.getChildById(e.colladaId,!0),r=null;if(t&&t.keys){r={fps:60,hierarchy:[{node:t,keys:t.keys,sids:t.sids}],node:e,name:"animation_"+e.name,length:0},_e.push(r);for(var a=0,i=t.keys.length;a=0){var n=t.invBindMatrices[i];a.invBindMatrix=n,a.skinningMatrix=new THREE.Matrix4,a.skinningMatrix.multiplyMatrices(a.world,n),a.animatrix=new THREE.Matrix4,a.animatrix.copy(a.localworld),a.weights=[];for(var s=0;ss.limits.max||r1)for(L=new THREE.MultiMaterial(b),s=0;s<_.faces.length;s++){var S=_.faces[s];S.materialIndex=T[S.daeMaterial]}void 0!==r?(m(_,r),_.morphTargets.length>0?(L.morphTargets=!0,L.skinning=!1):(L.morphTargets=!1,L.skinning=!0),H=new THREE.SkinnedMesh(_,L,!1),H.name="skin_"+Fe.length,Fe.push(H)):void 0!==a?(c(_,a),L.morphTargets=!0,H=new THREE.Mesh(_,L),H.name="morph_"+Ie.length,Ie.push(H)):H=_.isLineStrip===!0?new THREE.Line(_):new THREE.Mesh(_,L),n.add(H)}}for(i=0;it)break}return r}function R(e,t){for(var r=-1,a=0,i=e.length;a=t&&(r=a)}return r}function w(e,t,r,a){var i=A(e,a,r?r-1:0),s=x(e,a,r+1);if(i&&s){var n,o=(t.time-i.time)/(s.time-i.time),l=i.getTarget(a),h=s.getTarget(a).data,c=l.data;if("matrix"===l.type)n=c;else if(c.length){n=[];for(var u=0;u=0?r:r+e.length;r>=0;r--){var a=e[r];if(a.hasTarget(t))return a}return null}function N(){this.id="",this.init_from=""}function M(){this.id="",this.name="",this.type="",this.skin=null,this.morph=null}function H(){this.method=null,this.source=null,this.targets=null,this.weights=null}function L(){this.source="",this.bindShapeMatrix=null,this.invBindMatrices=[],this.joints=[],this.weights=[]}function _(){this.id="",this.name="",this.nodes=[],this.scene=new THREE.Group}function S(){this.id="",this.name="",this.sid="",this.nodes=[],this.controllers=[],this.transforms=[],this.geometries=[],this.channels=[],this.matrix=new THREE.Matrix4}function k(){this.sid="",this.type="",this.data=[],this.obj=null}function O(){this.url="",this.skeleton=[],this.instance_material=[]}function C(){this.symbol="",this.target=""}function I(){this.url="",this.instance_material=[]}function F(){this.id="",this.mesh=null}function j(e){this.geometry=e.id,this.primitives=[],this.vertices=null,this.geometry3js=null}function P(){this.material="",this.count=0,this.inputs=[],this.vcount=null,this.p=[],this.geometry=new THREE.Geometry}function U(){P.call(this),this.vcount=[]}function B(){P.call(this),this.vcount=1}function D(){P.call(this),this.vcount=3}function V(){this.source="",this.count=0,this.stride=0,this.params=[]}function G(){this.input={}}function Y(){this.semantic="",this.offset=0,this.source="",this.set=0}function q(e){this.id=e,this.type=null}function X(){this.id="",this.name="",this.instance_effect=null}function z(){this.color=new THREE.Color,this.color.setRGB(Math.random(),Math.random(),Math.random()),this.color.a=1,this.texture=null,this.texcoord=null,this.texOpts=null}function W(e,t){this.type=e,this.effect=t,this.material=null}function Z(e){this.effect=e,this.init_from=null,this.format=null}function K(e){this.effect=e,this.source=null,this.wrap_s=null,this.wrap_t=null,this.minfilter=null,this.magfilter=null,this.mipfilter=null}function J(){this.id="",this.name="",this.shader=null,this.surface={},this.sampler={}}function Q(){this.url=""}function $(){this.id="",this.name="",this.source={},this.sampler=[],this.channel=[]}function ee(e){this.animation=e,this.source="",this.target="",this.fullSid=null,this.sid=null,this.dotSyntax=null,this.arrSyntax=null,this.arrIndices=null,this.member=null}function te(e){this.id="",this.animation=e,this.inputs=[],this.input=null,this.output=null,this.strideOut=null,this.interpolation=null,this.startTime=null,this.endTime=null,this.duration=0}function re(e){this.targets=[],this.time=e}function ae(){this.id="",this.name="",this.technique=""}function ie(){this.url=""}function se(){this.id="",this.name="",this.technique=""}function ne(){ +this.url=""}function oe(){this.id="",this.name="",this.joints=[],this.links=[]}function le(){this.sid="",this.name="",this.axis=new THREE.Vector3,this.limits={min:0,max:0},this.type="",this.static=!1,this.zeroPosition=0,this.middlePosition=0}function he(){this.sid="",this.name="",this.transforms=[],this.attachments=[]}function ce(){this.joint="",this.transforms=[],this.links=[]}function ue(e){var t=e.getAttribute("id");return void 0!=Be[t]?Be[t]:(Be[t]=new q(t).parse(e),Be[t])}function de(e){for(var t=me(e),r=[],a=0,i=t.length;a0?Ee(e).split(/\s+/):[]}function Ee(e){return e.replace(/^\s+/,"").replace(/\s+$/,"")}function ve(e,t,r){return e.hasAttribute(t)?parseInt(e.getAttribute(t),10):r}function ge(e,t){if("string"!=typeof e||""===e)return"";if(/^(https?:)?\/\//i.test(e))return e;if(/^data:.*,.*$/i.test(e))return e;var r=new URL((t||"")+e,location.href.substring(0,location.href.lastIndexOf("/")+1));return r.toString()}function Te(e,t){var r=new THREE.ImageLoader;r.load(t,function(t){e.image=t,e.needsUpdate=!0})}function be(e,t){e.doubleSided=!1;var r=t.querySelectorAll("extra double_sided")[0];r&&r&&1===parseInt(r.textContent,10)&&(e.doubleSided=!0)}function ye(){if(Ke.convertUpAxis!==!0||Qe===Ke.upAxis)$e=null;else switch(Qe){case"X":$e="Y"===Ke.upAxis?"XtoY":"XtoZ";break;case"Y":$e="X"===Ke.upAxis?"YtoX":"YtoZ";break;case"Z":$e="X"===Ke.upAxis?"ZtoX":"ZtoY"}}function Re(e,t){if(Ke.convertUpAxis===!0&&Qe!==Ke.upAxis)switch($e){case"XtoY":var r=e[0];e[0]=t*e[1],e[1]=r;break;case"XtoZ":var r=e[2];e[2]=e[1],e[1]=e[0],e[0]=r;break;case"YtoX":var r=e[0];e[0]=e[1],e[1]=t*r;break;case"YtoZ":var r=e[1];e[1]=t*e[2],e[2]=r;break;case"ZtoX":var r=e[0];e[0]=e[1],e[1]=e[2],e[2]=r;break;case"ZtoY":var r=e[1];e[1]=e[2],e[2]=t*r}}function we(e,t){if(Ke.convertUpAxis!==!0||Qe===Ke.upAxis)return t;switch(e){case"X":t="XtoY"===$e?t*-1:t;break;case"Y":t="YtoZ"===$e||"YtoX"===$e?t*-1:t;break;case"Z":t="ZtoY"===$e?t*-1:t}return t}function xe(e,t){var r=[e[t],e[t+1],e[t+2]];return Re(r,-1),new THREE.Vector3(r[0],r[1],r[2])}function Ae(e){if(Ke.convertUpAxis){var t=[e[0],e[4],e[8]];Re(t,-1),e[0]=t[0],e[4]=t[1],e[8]=t[2],t=[e[1],e[5],e[9]],Re(t,-1),e[1]=t[0],e[5]=t[1],e[9]=t[2],t=[e[2],e[6],e[10]],Re(t,-1),e[2]=t[0],e[6]=t[1],e[10]=t[2],t=[e[0],e[1],e[2]],Re(t,-1),e[0]=t[0],e[1]=t[1],e[2]=t[2],t=[e[4],e[5],e[6]],Re(t,-1),e[4]=t[0],e[5]=t[1],e[6]=t[2],t=[e[8],e[9],e[10]],Re(t,-1),e[8]=t[0],e[9]=t[1],e[10]=t[2],t=[e[3],e[7],e[11]],Re(t,-1),e[3]=t[0],e[7]=t[1],e[11]=t[2]}return(new THREE.Matrix4).set(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15])}function Ne(e){if(e>-1&&e<3){var t=["X","Y","Z"],r={X:0,Y:1,Z:2};e=Me(t[e]),e=r[e]}return e}function Me(e){if(Ke.convertUpAxis)switch(e){case"X":switch($e){case"XtoY":case"XtoZ":case"YtoX":e="Y";break;case"ZtoX":e="Z"}break;case"Y":switch($e){case"XtoY":case"YtoX":case"ZtoX":e="X";break;case"XtoZ":case"YtoZ":case"ZtoY":e="Z"}break;case"Z":switch($e){case"XtoZ":e="X";break;case"YtoZ":case"ZtoX":case"ZtoY":e="Y"}}return e}var He,Le,_e,Se,ke,Oe,Ce,Ie,Fe,je=null,Pe=null,Ue=null,Be={},De={},Ve={},Ge={},Ye={},qe={},Xe={},ze={},We={},Ze=THREE.SmoothShading,Ke={centerGeometry:!1,convertUpAxis:!1,subdivideFaces:!0,upAxis:"Y",defaultEnvMap:null},Je=1,Qe="Y",$e=null;return N.prototype.parse=function(e){this.id=e.getAttribute("id");for(var t=0;t=0,l=n.indexOf("(")>=0;if(o)s=n.split("."),n=s.shift(),a=s.shift();else if(l){r=n.split("("),n=r.shift();for(var h=0;h4&&Ke.subdivideFaces){var L=R.length?R:new THREE.Color;for(a=1;a4?[A[0],A[w+1],A[w+2]]:4===d?0===w?[A[0],A[1],A[3]]:[A[1].clone(),A[2],A[3].clone()]:[A[0],A[1],A[2]],void 0===t.faceVertexUvs[a]&&(t.faceVertexUvs[a]=[]),t.faceVertexUvs[a].push(N);else console.log("dropped face with vcount "+d+" for geometry with id: "+t.id);g+=p*d}},P.prototype.setVertices=function(e){for(var t=0;t0&&(this[r.nodeName]=parseFloat(i[0].textContent))}}return this.create(),this},W.prototype.create=function(){var e={},t=!1;if(void 0!==this.transparency&&void 0!==this.transparent){var r=(this.transparent,(this.transparent.color.r+this.transparent.color.g+this.transparent.color.b)/3*this.transparency);r>0&&(t=!0,e.transparent=!0,e.opacity=1-r)}var a={diffuse:"map",ambient:"lightMap",specular:"specularMap",emission:"emissionMap",bump:"bumpMap",normal:"normalMap"};for(var i in this)switch(i){case"ambient":case"emission":case"diffuse":case"specular":case"bump":case"normal":var s=this[i];if(s instanceof z)if(s.isTexture()){var n=s.texture,o=this.effect.sampler[n];if(void 0!==o&&void 0!==o.source){var l=this.effect.surface[o.source];if(void 0!==l){var h=De[l.init_from];if(h){var c,u=Ce+h.init_from;if(altspace&&altspace.inClient)c=new THREE.Texture({src:ge(u)});else{var d=THREE.Loader.Handlers.get(u);null!==d?c=d.load(u):(c=new THREE.Texture,Te(c,u))}"MIRROR"===o.wrap_s?c.wrapS=THREE.MirroredRepeatWrapping:"WRAP"===o.wrap_s||s.texOpts.wrapU?c.wrapS=THREE.RepeatWrapping:c.wrapS=THREE.ClampToEdgeWrapping,"MIRROR"===o.wrap_t?c.wrapT=THREE.MirroredRepeatWrapping:"WRAP"===o.wrap_t||s.texOpts.wrapV?c.wrapT=THREE.RepeatWrapping:c.wrapT=THREE.ClampToEdgeWrapping,c.offset.x=s.texOpts.offsetU,c.offset.y=s.texOpts.offsetV,c.repeat.x=s.texOpts.repeatU,c.repeat.y=s.texOpts.repeatV,e[a[i]]=c,"emission"===i&&(e.emissive=16777215)}}}}else"diffuse"!==i&&t||("emission"===i?e.emissive=s.color.getHex():e[i]=s.color.getHex());break;case"shininess":e[i]=this[i];break;case"reflectivity":e[i]=this[i],e[i]>0&&(e.envMap=Ke.defaultEnvMap),e.combine=THREE.MixOperation;break;case"index_of_refraction":e.refractionRatio=this[i],1!==this[i]&&(e.envMap=Ke.defaultEnvMap);break;case"transparency":}switch(e.shading=Ze,e.side=this.effect.doubleSided?THREE.DoubleSide:THREE.FrontSide,void 0!==e.diffuse&&(e.color=e.diffuse,delete e.diffuse),this.type){case"constant":void 0!=e.emissive&&(e.color=e.emissive),this.material=new THREE.MeshBasicMaterial(e);break;case"phong":case"blinn":this.material=new THREE.MeshPhongMaterial(e);break;case"lambert":default:this.material=new THREE.MeshLambertMaterial(e)}return this.material},Z.prototype.parse=function(e){for(var t=0;t=0,i=r.indexOf("(")>=0;if(a)t=r.split("."),this.sid=t.shift(),this.member=t.shift();else if(i){var s=r.split("(");this.sid=s.shift();for(var n=0;n1){a=[],t*=this.strideOut;for(var i=0;i1&&(o=1),h.length){i=[];for(var c=0;c=this.limits.max&&(this.static=!0), +this.middlePosition=(this.limits.min+this.limits.max)/2,this},he.prototype.parse=function(e){this.sid=e.getAttribute("sid"),this.name=e.getAttribute("name"),this.transforms=[],this.attachments=[];for(var t=0;t=0&&(n[u.KHR_MATERIALS_COMMON]=new a(h)),console.time("GLTFLoader");var d=new c(h,n,{path:r||this.path,crossOrigin:this.crossOrigin});d.parse(function(e,r,a,i){console.log("------------ UltimateLoader ---------------"),console.timeEnd("GLTFLoader");var s={scene:e,scenes:r,cameras:a,animations:i};t(s)})}},e.Shaders={update:function(){console.warn("THREE.GLTFLoader.Shaders has been deprecated, and now updates automatically.")}},r.prototype.update=function(e,t){var r=this.boundUniforms;for(var a in r){var i=r[a];switch(i.semantic){case"MODELVIEW":var s=i.uniform.value;s.multiplyMatrices(t.matrixWorldInverse,i.sourceNode.matrixWorld);break;case"MODELVIEWINVERSETRANSPOSE":var n=i.uniform.value;this._m4.multiplyMatrices(t.matrixWorldInverse,i.sourceNode.matrixWorld),n.getNormalMatrix(this._m4);break;case"PROJECTION":var s=i.uniform.value;s.copy(t.projectionMatrix);break;case"JOINTMATRIX":for(var o=i.uniform.value,l=0;l0?new Uint8Array(g.buffer,T,e):new Uint8Array);return T+=Uint8Array.BYTES_PER_ELEMENT*e,t}function n(e){if(T%Uint16Array.BYTES_PER_ELEMENT===0){var t=new Uint16Array(g.buffer,T,e);return T+=Uint16Array.BYTES_PER_ELEMENT*e,t}for(var t=new Uint16Array(e),r=0;r0?THREE.SmoothShading:THREE.FlatShading,this.debug&&console.log("Group Material",$,C)}var ee=new THREE.Mesh(Q,C);W&&(ee.name=W),P.add(ee)}}}}return this.performanceTimer&&console.timeEnd("BOMLoader"),y}},THREE.BOMLoaderUtil=THREE.BOMLoaderUtil||{},THREE.BOMLoaderUtil.multiload=function(e,t){function r(e,r){var s=new THREE.BOMLoader;s.setTexturePath(r.url.split("/").slice(0,-1).join("/")+"/"),void 0!==r.debug&&s.setDebug(r.debug),void 0!==r.timer&&s.setPerfTimer(r.timer),void 0!==r.crossOrigin&&s.setCrossOrigin(r.crossOrigin),void 0!==r.responseType&&s.setResponseType(r.responseType),s.load(r.url,function(s){r.object=s,i[e]=r,--a<=0&&t(i)})}e=e.constructor===Array?e:[e];for(var a=e.length,i=[],s=0;s=0?n.substring(0,o):n;l=l.toLowerCase();var c=o>=0?n.substring(o+1):"";if(c=c.trim(),"newmtl"===l)r={name:c},i[c]=r;else if(r)if("ka"===l||"kd"===l||"ks"===l){var h=c.split(a,3);r[l]=[parseFloat(h[0]),parseFloat(h[1]),parseFloat(h[2])]}else r[l]=c}}var u=new THREE.MTLLoader.MaterialCreator(this.texturePath||this.path,this.materialOptions);return u.setCrossOrigin(this.crossOrigin),u.setManager(this.manager),u.setMaterials(i),u}},THREE.MTLLoader.MaterialCreator=function(e,t){this.baseUrl=e||"",this.options=t,this.materialsInfo={},this.materials={},this.materialsArray=[],this.nameLookup={},this.side=this.options&&this.options.side?this.options.side:THREE.FrontSide,this.wrap=this.options&&this.options.wrap?this.options.wrap:THREE.RepeatWrapping},THREE.MTLLoader.MaterialCreator.prototype={constructor:THREE.MTLLoader.MaterialCreator,setCrossOrigin:function(e){this.crossOrigin=e},setManager:function(e){this.manager=e},setMaterials:function(e){this.materialsInfo=this.convert(e),this.materials={},this.materialsArray=[],this.nameLookup={}},convert:function(e){if(!this.options)return e;var t={};for(var r in e){var a=e[r],i={};t[r]=i;for(var s in a){var n=!0,o=a[s],l=s.toLowerCase();switch(l){case"kd":case"ka":case"ks":this.options&&this.options.normalizeRGB&&(o=[o[0]/255,o[1]/255,o[2]/255]),this.options&&this.options.ignoreZeroRGBs&&0===o[0]&&0===o[1]&&0===o[2]&&(n=!1)}n&&(i[l]=o)}}return t},preload:function(){for(var e in this.materialsInfo)this.create(e)},getIndex:function(e){return this.nameLookup[e]},getAsArray:function(){var e=0;for(var t in this.materialsInfo)this.materialsArray[e]=this.create(t),this.nameLookup[t]=e,e++;return this.materialsArray},create:function(e){return void 0===this.materials[e]&&this.createMaterial_(e),this.materials[e]},createMaterial_:function(e){function t(e,t){return"string"!=typeof t||""===t?"":/^https?:\/\//i.test(t)?t:e+t}function r(e,r){if(!s[e]){var i=a.getTextureParams(r,s),n=a.loadTexture(t(a.baseUrl,i.url));n.repeat.copy(i.scale),n.offset.copy(i.offset),n.wrapS=a.wrap,n.wrapT=a.wrap,s[e]=n}}var a=this,i=this.materialsInfo[e],s={name:e,side:this.side};for(var n in i){var o=i[n];if(""!==o)switch(n.toLowerCase()){case"kd":s.color=(new THREE.Color).fromArray(o);break;case"ks":s.specular=(new THREE.Color).fromArray(o);break;case"map_kd":r("map",o);break;case"map_ks":r("specularMap",o);break;case"map_bump":case"bump":r("bumpMap",o);break;case"ns":s.shininess=parseFloat(o);break;case"d":o<1&&(s.opacity=o,s.transparent=!0);break;case"Tr":o>0&&(s.opacity=1-o,s.transparent=!0)}}return this.materials[e]=new THREE.MeshPhongMaterial(s),this.materials[e]},getTextureParams:function(e,t){var r,a={scale:new THREE.Vector2(1,1),offset:new THREE.Vector2(0,0)},i=e.split(/\s+/);return r=i.indexOf("-bm"),r>=0&&(t.bumpScale=parseFloat(i[r+1]),i.splice(r,2)),r=i.indexOf("-s"),r>=0&&(a.scale.set(parseFloat(i[r+1]),parseFloat(i[r+2])),i.splice(r,4)),r=i.indexOf("-o"),r>=0&&(a.offset.set(parseFloat(i[r+1]),parseFloat(i[r+2])),i.splice(r,4)),a.url=i.join(" ").trim(),a},loadTexture:function(e,t,r,a,i){var s;if(altspace&&altspace.inClient)s=new THREE.Texture({src:e});else{var n=THREE.Loader.Handlers.get(e),o=void 0!==this.manager?this.manager:THREE.DefaultLoadingManager;null===n&&(n=new THREE.TextureLoader(o)),n.setCrossOrigin&&n.setCrossOrigin(this.crossOrigin),s=n.load(e,r,a,i)}return void 0!==t&&(s.mapping=t),s}},THREE.OBJLoader=function(e){this.manager=void 0!==e?e:THREE.DefaultLoadingManager,this.materials=null,this.regexp={vertex_pattern:/^v\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,normal_pattern:/^vn\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,uv_pattern:/^vt\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,face_vertex:/^f\s+(-?\d+)\s+(-?\d+)\s+(-?\d+)(?:\s+(-?\d+))?/,face_vertex_uv:/^f\s+(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)(?:\s+(-?\d+)\/(-?\d+))?/,face_vertex_uv_normal:/^f\s+(-?\d+)\/(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\/(-?\d+)(?:\s+(-?\d+)\/(-?\d+)\/(-?\d+))?/,face_vertex_normal:/^f\s+(-?\d+)\/\/(-?\d+)\s+(-?\d+)\/\/(-?\d+)\s+(-?\d+)\/\/(-?\d+)(?:\s+(-?\d+)\/\/(-?\d+))?/,object_pattern:/^[og]\s*(.+)?/,smoothing_pattern:/^s\s+(\d+|on|off)/,material_library_pattern:/^mtllib /,material_use_pattern:/^usemtl /}},THREE.OBJLoader.prototype={constructor:THREE.OBJLoader,load:function(e,t,r,a){var i=this,s=new THREE.FileLoader(i.manager);s.setPath(this.path),s.load(e,function(e){t(i.parse(e))},r,a)},setPath:function(e){this.path=e},setMaterials:function(e){this.materials=e},_createParserState:function(){var e={objects:[],object:{},vertices:[],normals:[],uvs:[],materialLibraries:[],startObject:function(e,t){if(this.object&&this.object.fromDeclaration===!1)return this.object.name=e,void(this.object.fromDeclaration=t!==!1);var r=this.object&&"function"==typeof this.object.currentMaterial?this.object.currentMaterial():void 0;if(this.object&&"function"==typeof this.object._finalize&&this.object._finalize(!0),this.object={name:e||"",fromDeclaration:t!==!1,geometry:{vertices:[],normals:[],uvs:[]},materials:[],smooth:!0,startMaterial:function(e,t){var r=this._finalize(!1);r&&(r.inherited||r.groupCount<=0)&&this.materials.splice(r.index,1);var a={index:this.materials.length,name:e||"",mtllib:Array.isArray(t)&&t.length>0?t[t.length-1]:"",smooth:void 0!==r?r.smooth:this.smooth,groupStart:void 0!==r?r.groupEnd:0,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(e){var t={index:"number"==typeof e?e:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return t.clone=this.clone.bind(t),t}};return this.materials.push(a),a},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(e){var t=this.currentMaterial();if(t&&t.groupEnd===-1&&(t.groupEnd=this.geometry.vertices.length/3,t.groupCount=t.groupEnd-t.groupStart,t.inherited=!1),e&&this.materials.length>1)for(var r=this.materials.length-1;r>=0;r--)this.materials[r].groupCount<=0&&this.materials.splice(r,1);return e&&0===this.materials.length&&this.materials.push({name:"",smooth:this.smooth}),t}},r&&r.name&&"function"==typeof r.clone){var a=r.clone(0);a.inherited=!0,this.object.materials.push(a)}this.objects.push(this.object)},finalize:function(){this.object&&"function"==typeof this.object._finalize&&this.object._finalize(!0)},parseVertexIndex:function(e,t){var r=parseInt(e,10);return 3*(r>=0?r-1:r+t/3)},parseNormalIndex:function(e,t){var r=parseInt(e,10);return 3*(r>=0?r-1:r+t/3)},parseUVIndex:function(e,t){var r=parseInt(e,10);return 2*(r>=0?r-1:r+t/2)},addVertex:function(e,t,r){var a=this.vertices,i=this.object.geometry.vertices;i.push(a[e+0]),i.push(a[e+1]),i.push(a[e+2]),i.push(a[t+0]),i.push(a[t+1]),i.push(a[t+2]),i.push(a[r+0]),i.push(a[r+1]),i.push(a[r+2])},addVertexLine:function(e){var t=this.vertices,r=this.object.geometry.vertices;r.push(t[e+0]),r.push(t[e+1]),r.push(t[e+2])},addNormal:function(e,t,r){var a=this.normals,i=this.object.geometry.normals;i.push(a[e+0]),i.push(a[e+1]),i.push(a[e+2]),i.push(a[t+0]),i.push(a[t+1]),i.push(a[t+2]),i.push(a[r+0]),i.push(a[r+1]),i.push(a[r+2])},addUV:function(e,t,r){var a=this.uvs,i=this.object.geometry.uvs;i.push(a[e+0]),i.push(a[e+1]),i.push(a[t+0]),i.push(a[t+1]),i.push(a[r+0]),i.push(a[r+1])},addUVLine:function(e){var t=this.uvs,r=this.object.geometry.uvs;r.push(t[e+0]),r.push(t[e+1])},addFace:function(e,t,r,a,i,s,n,o,l,c,h,u){var d,p=this.vertices.length,f=this.parseVertexIndex(e,p),m=this.parseVertexIndex(t,p),E=this.parseVertexIndex(r,p);if(void 0===a?this.addVertex(f,m,E):(d=this.parseVertexIndex(a,p),this.addVertex(f,m,d),this.addVertex(m,E,d)),void 0!==i){var v=this.uvs.length;f=this.parseUVIndex(i,v),m=this.parseUVIndex(s,v),E=this.parseUVIndex(n,v),void 0===a?this.addUV(f,m,E):(d=this.parseUVIndex(o,v),this.addUV(f,m,d),this.addUV(m,E,d))}if(void 0!==l){var g=this.normals.length;f=this.parseNormalIndex(l,g),m=l===c?f:this.parseNormalIndex(c,g),E=l===h?f:this.parseNormalIndex(h,g),void 0===a?this.addNormal(f,m,E):(d=this.parseNormalIndex(u,g),this.addNormal(f,m,d),this.addNormal(m,E,d))}},addLineGeometry:function(e,t){this.object.geometry.type="Line";for(var r=this.vertices.length,a=this.uvs.length,i=0,s=e.length;i0?A.addAttribute("normal",new THREE.BufferAttribute(new Float32Array(R.normals),3)):A.computeVertexNormals(),R.uvs.length>0&&A.addAttribute("uv",new THREE.BufferAttribute(new Float32Array(R.uvs),2));for(var N=[],M=0,H=w.length;M1){for(var M=0,H=w.length;M0?t:"visual_scene0"]}return null}function n(){var e=Fe.querySelectorAll("instance_kinematics_model")[0];if(e){var t=e.getAttribute("url").replace(/^#/,"");return ke[t.length>0?t:"kinematics_model0"]}return null}function o(){_e=[],l(Pe)}function l(e){var t=He.getChildById(e.colladaId,!0),r=null;if(t&&t.keys){r={fps:60,hierarchy:[{node:t,keys:t.keys,sids:t.sids}],node:e,name:"animation_"+e.name,length:0},_e.push(r);for(var a=0,i=t.keys.length;a=0){var n=t.invBindMatrices[i];a.invBindMatrix=n,a.skinningMatrix=new THREE.Matrix4,a.skinningMatrix.multiplyMatrices(a.world,n),a.animatrix=new THREE.Matrix4,a.animatrix.copy(a.localworld),a.weights=[];for(var s=0;ss.limits.max||r1)for(L=new THREE.MultiMaterial(b),s=0;s<_.faces.length;s++){var S=_.faces[s];S.materialIndex=T[S.daeMaterial]}void 0!==r?(m(_,r),_.morphTargets.length>0?(L.morphTargets=!0,L.skinning=!1):(L.morphTargets=!1,L.skinning=!0),H=new THREE.SkinnedMesh(_,L,!1),H.name="skin_"+je.length,je.push(H)):void 0!==a?(h(_,a),L.morphTargets=!0,H=new THREE.Mesh(_,L),H.name="morph_"+Ie.length,Ie.push(H)):H=_.isLineStrip===!0?new THREE.Line(_):new THREE.Mesh(_,L),n.add(H)}}for(i=0;it)break}return r}function R(e,t){for(var r=-1,a=0,i=e.length;a=t&&(r=a)}return r}function w(e,t,r,a){var i=A(e,a,r?r-1:0),s=x(e,a,r+1);if(i&&s){var n,o=(t.time-i.time)/(s.time-i.time),l=i.getTarget(a),c=s.getTarget(a).data,h=l.data;if("matrix"===l.type)n=h;else if(h.length){n=[];for(var u=0;u=0?r:r+e.length;r>=0;r--){var a=e[r];if(a.hasTarget(t))return a}return null}function N(){this.id="",this.init_from=""}function M(){this.id="",this.name="",this.type="",this.skin=null,this.morph=null}function H(){this.method=null,this.source=null,this.targets=null,this.weights=null}function L(){this.source="",this.bindShapeMatrix=null,this.invBindMatrices=[],this.joints=[],this.weights=[]}function _(){this.id="",this.name="",this.nodes=[],this.scene=new THREE.Group}function S(){this.id="",this.name="",this.sid="",this.nodes=[],this.controllers=[],this.transforms=[],this.geometries=[],this.channels=[],this.matrix=new THREE.Matrix4}function O(){this.sid="",this.type="",this.data=[],this.obj=null}function k(){this.url="",this.skeleton=[],this.instance_material=[]}function C(){this.symbol="",this.target=""}function I(){this.url="",this.instance_material=[]}function j(){this.id="",this.mesh=null}function F(e){this.geometry=e.id,this.primitives=[],this.vertices=null,this.geometry3js=null}function P(){this.material="",this.count=0,this.inputs=[],this.vcount=null,this.p=[],this.geometry=new THREE.Geometry}function U(){P.call(this),this.vcount=[]}function B(){P.call(this),this.vcount=1}function D(){P.call(this),this.vcount=3}function V(){this.source="",this.count=0,this.stride=0,this.params=[]}function G(){this.input={}}function Y(){this.semantic="",this.offset=0,this.source="",this.set=0}function q(e){this.id=e,this.type=null}function z(){this.id="",this.name="",this.instance_effect=null}function X(){this.color=new THREE.Color,this.color.setRGB(Math.random(),Math.random(),Math.random()),this.color.a=1,this.texture=null,this.texcoord=null,this.texOpts=null}function W(e,t){this.type=e,this.effect=t,this.material=null}function Z(e){this.effect=e,this.init_from=null,this.format=null}function K(e){this.effect=e,this.source=null,this.wrap_s=null,this.wrap_t=null,this.minfilter=null,this.magfilter=null,this.mipfilter=null}function J(){this.id="",this.name="",this.shader=null,this.surface={},this.sampler={}}function Q(){this.url=""}function $(){this.id="",this.name="",this.source={},this.sampler=[],this.channel=[]}function ee(e){this.animation=e,this.source="",this.target="",this.fullSid=null,this.sid=null,this.dotSyntax=null,this.arrSyntax=null,this.arrIndices=null,this.member=null}function te(e){this.id="",this.animation=e,this.inputs=[],this.input=null,this.output=null,this.strideOut=null,this.interpolation=null,this.startTime=null,this.endTime=null,this.duration=0}function re(e){this.targets=[],this.time=e}function ae(){this.id="",this.name="",this.technique=""}function ie(){this.url=""}function se(){this.id="",this.name="",this.technique=""}function ne(){this.url=""}function oe(){this.id="",this.name="",this.joints=[],this.links=[]}function le(){this.sid="",this.name="",this.axis=new THREE.Vector3,this.limits={min:0,max:0},this.type="",this.static=!1,this.zeroPosition=0,this.middlePosition=0}function ce(){this.sid="",this.name="",this.transforms=[],this.attachments=[]}function he(){this.joint="",this.transforms=[],this.links=[]}function ue(e){var t=e.getAttribute("id");return void 0!=Be[t]?Be[t]:(Be[t]=new q(t).parse(e),Be[t])}function de(e){for(var t=me(e),r=[],a=0,i=t.length;a0?Ee(e).split(/\s+/):[]}function Ee(e){return e.replace(/^\s+/,"").replace(/\s+$/,"")}function ve(e,t,r){return e.hasAttribute(t)?parseInt(e.getAttribute(t),10):r}function ge(e,t){if("string"!=typeof e||""===e)return"";if(/^(https?:)?\/\//i.test(e))return e;if(/^data:.*,.*$/i.test(e))return e;var r=new URL((t||"")+e,location.href.substring(0,location.href.lastIndexOf("/")+1));return r.toString()}function Te(e,t){var r=new THREE.ImageLoader;r.load(t,function(t){e.image=t,e.needsUpdate=!0})}function be(e,t){e.doubleSided=!1;var r=t.querySelectorAll("extra double_sided")[0];r&&r&&1===parseInt(r.textContent,10)&&(e.doubleSided=!0)}function ye(){if(Ke.convertUpAxis!==!0||Qe===Ke.upAxis)$e=null;else switch(Qe){case"X":$e="Y"===Ke.upAxis?"XtoY":"XtoZ";break;case"Y":$e="X"===Ke.upAxis?"YtoX":"YtoZ";break;case"Z":$e="X"===Ke.upAxis?"ZtoX":"ZtoY"}}function Re(e,t){if(Ke.convertUpAxis===!0&&Qe!==Ke.upAxis)switch($e){case"XtoY":var r=e[0];e[0]=t*e[1],e[1]=r;break;case"XtoZ":var r=e[2];e[2]=e[1],e[1]=e[0],e[0]=r;break;case"YtoX":var r=e[0];e[0]=e[1],e[1]=t*r;break;case"YtoZ":var r=e[1];e[1]=t*e[2],e[2]=r;break;case"ZtoX":var r=e[0];e[0]=e[1],e[1]=e[2],e[2]=r;break;case"ZtoY":var r=e[1];e[1]=e[2],e[2]=t*r}}function we(e,t){if(Ke.convertUpAxis!==!0||Qe===Ke.upAxis)return t;switch(e){case"X":t="XtoY"===$e?t*-1:t;break;case"Y":t="YtoZ"===$e||"YtoX"===$e?t*-1:t;break;case"Z":t="ZtoY"===$e?t*-1:t}return t}function xe(e,t){var r=[e[t],e[t+1],e[t+2]];return Re(r,-1),new THREE.Vector3(r[0],r[1],r[2])}function Ae(e){if(Ke.convertUpAxis){var t=[e[0],e[4],e[8]];Re(t,-1),e[0]=t[0],e[4]=t[1],e[8]=t[2],t=[e[1],e[5],e[9]],Re(t,-1),e[1]=t[0],e[5]=t[1],e[9]=t[2],t=[e[2],e[6],e[10]],Re(t,-1),e[2]=t[0],e[6]=t[1],e[10]=t[2],t=[e[0],e[1],e[2]],Re(t,-1),e[0]=t[0],e[1]=t[1],e[2]=t[2],t=[e[4],e[5],e[6]],Re(t,-1),e[4]=t[0],e[5]=t[1],e[6]=t[2],t=[e[8],e[9],e[10]],Re(t,-1),e[8]=t[0],e[9]=t[1],e[10]=t[2],t=[e[3],e[7],e[11]],Re(t,-1),e[3]=t[0],e[7]=t[1],e[11]=t[2]}return(new THREE.Matrix4).set(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15])}function Ne(e){if(e>-1&&e<3){var t=["X","Y","Z"],r={X:0,Y:1,Z:2};e=Me(t[e]),e=r[e]}return e}function Me(e){if(Ke.convertUpAxis)switch(e){case"X":switch($e){case"XtoY":case"XtoZ":case"YtoX":e="Y";break;case"ZtoX":e="Z"}break;case"Y":switch($e){case"XtoY":case"YtoX":case"ZtoX":e="X";break;case"XtoZ":case"YtoZ":case"ZtoY":e="Z"}break;case"Z":switch($e){case"XtoZ":e="X";break;case"YtoZ":case"ZtoX":case"ZtoY":e="Y"}}return e}var He,Le,_e,Se,Oe,ke,Ce,Ie,je,Fe=null,Pe=null,Ue=null,Be={},De={},Ve={},Ge={},Ye={},qe={},ze={},Xe={},We={},Ze=THREE.SmoothShading,Ke={centerGeometry:!1,convertUpAxis:!1,subdivideFaces:!0,upAxis:"Y",defaultEnvMap:null},Je=1,Qe="Y",$e=null;return N.prototype.parse=function(e){this.id=e.getAttribute("id");for(var t=0;t=0,l=n.indexOf("(")>=0;if(o)s=n.split("."),n=s.shift(),a=s.shift();else if(l){r=n.split("("),n=r.shift();for(var c=0;c4&&Ke.subdivideFaces){var L=R.length?R:new THREE.Color;for(a=1;a4?[A[0],A[w+1],A[w+2]]:4===d?0===w?[A[0],A[1],A[3]]:[A[1].clone(),A[2],A[3].clone()]:[A[0],A[1],A[2]],void 0===t.faceVertexUvs[a]&&(t.faceVertexUvs[a]=[]),t.faceVertexUvs[a].push(N);else console.log("dropped face with vcount "+d+" for geometry with id: "+t.id);g+=p*d}},P.prototype.setVertices=function(e){for(var t=0;t0&&(this[r.nodeName]=parseFloat(i[0].textContent))}}return this.create(),this},W.prototype.create=function(){var e={},t=!1;if(void 0!==this.transparency&&void 0!==this.transparent){var r=(this.transparent,(this.transparent.color.r+this.transparent.color.g+this.transparent.color.b)/3*this.transparency);r>0&&(t=!0,e.transparent=!0,e.opacity=1-r)}var a={diffuse:"map",ambient:"lightMap",specular:"specularMap",emission:"emissionMap",bump:"bumpMap",normal:"normalMap"};for(var i in this)switch(i){case"ambient":case"emission":case"diffuse":case"specular":case"bump":case"normal":var s=this[i];if(s instanceof X)if(s.isTexture()){var n=s.texture,o=this.effect.sampler[n];if(void 0!==o&&void 0!==o.source){var l=this.effect.surface[o.source];if(void 0!==l){var c=De[l.init_from];if(c){var h,u=Ce+c.init_from;if(altspace&&altspace.inClient)h=new THREE.Texture({src:ge(u)});else{var d=THREE.Loader.Handlers.get(u);null!==d?h=d.load(u):(h=new THREE.Texture,Te(h,u))}"MIRROR"===o.wrap_s?h.wrapS=THREE.MirroredRepeatWrapping:"WRAP"===o.wrap_s||s.texOpts.wrapU?h.wrapS=THREE.RepeatWrapping:h.wrapS=THREE.ClampToEdgeWrapping,"MIRROR"===o.wrap_t?h.wrapT=THREE.MirroredRepeatWrapping:"WRAP"===o.wrap_t||s.texOpts.wrapV?h.wrapT=THREE.RepeatWrapping:h.wrapT=THREE.ClampToEdgeWrapping,h.offset.x=s.texOpts.offsetU,h.offset.y=s.texOpts.offsetV,h.repeat.x=s.texOpts.repeatU,h.repeat.y=s.texOpts.repeatV,e[a[i]]=h,"emission"===i&&(e.emissive=16777215)}}}}else"diffuse"!==i&&t||("emission"===i?e.emissive=s.color.getHex():e[i]=s.color.getHex());break;case"shininess":e[i]=this[i];break;case"reflectivity":e[i]=this[i],e[i]>0&&(e.envMap=Ke.defaultEnvMap),e.combine=THREE.MixOperation;break;case"index_of_refraction":e.refractionRatio=this[i],1!==this[i]&&(e.envMap=Ke.defaultEnvMap);break;case"transparency":}switch(e.shading=Ze,e.side=this.effect.doubleSided?THREE.DoubleSide:THREE.FrontSide,void 0!==e.diffuse&&(e.color=e.diffuse,delete e.diffuse),this.type){case"constant":void 0!=e.emissive&&(e.color=e.emissive),this.material=new THREE.MeshBasicMaterial(e);break;case"phong":case"blinn":this.material=new THREE.MeshPhongMaterial(e);break;case"lambert":default:this.material=new THREE.MeshLambertMaterial(e)}return this.material},Z.prototype.parse=function(e){for(var t=0;t=0,i=r.indexOf("(")>=0;if(a)t=r.split("."),this.sid=t.shift(),this.member=t.shift();else if(i){var s=r.split("(");this.sid=s.shift();for(var n=0;n1){a=[],t*=this.strideOut;for(var i=0;i1&&(o=1),c.length){i=[];for(var h=0;h=this.limits.max&&(this.static=!0),this.middlePosition=(this.limits.min+this.limits.max)/2,this},ce.prototype.parse=function(e){this.sid=e.getAttribute("sid"),this.name=e.getAttribute("name"),this.transforms=[],this.attachments=[];for(var t=0;t=0&&(n[u.KHR_MATERIALS_COMMON]=new a(c)),console.time("GLTFLoader");var d=new h(c,n,{path:r||this.path,crossOrigin:this.crossOrigin});d.parse(function(e,r,a,i){console.log("------------ UltimateLoader ---------------"),console.timeEnd("GLTFLoader");var s={scene:e,scenes:r,cameras:a,animations:i};t(s)})}},e.Shaders={update:function(){console.warn("THREE.GLTFLoader.Shaders has been deprecated, and now updates automatically.")}},r.prototype.update=function(e,t){var r=this.boundUniforms;for(var a in r){var i=r[a];switch(i.semantic){case"MODELVIEW":var s=i.uniform.value;s.multiplyMatrices(t.matrixWorldInverse,i.sourceNode.matrixWorld);break;case"MODELVIEWINVERSETRANSPOSE":var n=i.uniform.value;this._m4.multiplyMatrices(t.matrixWorldInverse,i.sourceNode.matrixWorld),n.getNormalMatrix(this._m4);break;case"PROJECTION":var s=i.uniform.value;s.copy(t.projectionMatrix);break;case"JOINTMATRIX":for(var o=i.uniform.value,l=0;l0?new Uint8Array(g.buffer,T,e):new Uint8Array);return T+=Uint8Array.BYTES_PER_ELEMENT*e,t}function n(e){if(T%Uint16Array.BYTES_PER_ELEMENT===0){var t=new Uint16Array(g.buffer,T,e);return T+=Uint16Array.BYTES_PER_ELEMENT*e,t}for(var t=new Uint16Array(e),r=0;r0?THREE.SmoothShading:THREE.FlatShading,this.debug&&console.log("Group Material",$,C)}var ee=new THREE.Mesh(Q,C);W&&(ee.name=W),P.add(ee)}}}}return this.performanceTimer&&console.timeEnd("BOMLoader"),y}},THREE.BOMLoaderUtil=THREE.BOMLoaderUtil||{},THREE.BOMLoaderUtil.multiload=function(e,t){function r(e,r){var s=new THREE.BOMLoader;s.setTexturePath(r.url.split("/").slice(0,-1).join("/")+"/"),void 0!==r.debug&&s.setDebug(r.debug),void 0!==r.timer&&s.setPerfTimer(r.timer),void 0!==r.crossOrigin&&s.setCrossOrigin(r.crossOrigin),void 0!==r.responseType&&s.setResponseType(r.responseType),s.load(r.url,function(s){r.object=s,i[e]=r,--a<=0&&t(i)})}e=e.constructor===Array?e:[e];for(var a=e.length,i=[],s=0;s=0?n.substring(0,o):n;l=l.toLowerCase();var c=o>=0?n.substring(o+1):"";if(c=c.trim(),"newmtl"===l)r={name:c},i[c]=r;else if(r)if("ka"===l||"kd"===l||"ks"===l){var h=c.split(a,3);r[l]=[parseFloat(h[0]),parseFloat(h[1]),parseFloat(h[2])]}else r[l]=c}}var u=new THREE.MTLLoader.MaterialCreator(this.texturePath||this.path,this.materialOptions);return u.setCrossOrigin(this.crossOrigin),u.setManager(this.manager),u.setMaterials(i),u}},THREE.MTLLoader.MaterialCreator=function(e,t){this.baseUrl=e||"",this.options=t,this.materialsInfo={},this.materials={},this.materialsArray=[],this.nameLookup={},this.side=this.options&&this.options.side?this.options.side:THREE.FrontSide,this.wrap=this.options&&this.options.wrap?this.options.wrap:THREE.RepeatWrapping},THREE.MTLLoader.MaterialCreator.prototype={constructor:THREE.MTLLoader.MaterialCreator,setCrossOrigin:function(e){this.crossOrigin=e},setManager:function(e){this.manager=e},setMaterials:function(e){this.materialsInfo=this.convert(e),this.materials={},this.materialsArray=[],this.nameLookup={}},convert:function(e){if(!this.options)return e;var t={};for(var r in e){var a=e[r],i={};t[r]=i;for(var s in a){var n=!0,o=a[s],l=s.toLowerCase();switch(l){case"kd":case"ka":case"ks":this.options&&this.options.normalizeRGB&&(o=[o[0]/255,o[1]/255,o[2]/255]),this.options&&this.options.ignoreZeroRGBs&&0===o[0]&&0===o[1]&&0===o[2]&&(n=!1)}n&&(i[l]=o)}}return t},preload:function(){for(var e in this.materialsInfo)this.create(e)},getIndex:function(e){return this.nameLookup[e]},getAsArray:function(){var e=0;for(var t in this.materialsInfo)this.materialsArray[e]=this.create(t),this.nameLookup[t]=e,e++;return this.materialsArray},create:function(e){return void 0===this.materials[e]&&this.createMaterial_(e),this.materials[e]},createMaterial_:function(e){function t(e,t){return"string"!=typeof t||""===t?"":/^https?:\/\//i.test(t)?t:e+t}function r(e,r){if(!s[e]){var i=a.getTextureParams(r,s),n=a.loadTexture(t(a.baseUrl,i.url));n.repeat.copy(i.scale),n.offset.copy(i.offset),n.wrapS=a.wrap,n.wrapT=a.wrap,s[e]=n}}var a=this,i=this.materialsInfo[e],s={name:e,side:this.side};for(var n in i){var o=i[n];if(""!==o)switch(n.toLowerCase()){case"kd":s.color=(new THREE.Color).fromArray(o);break;case"ks":s.specular=(new THREE.Color).fromArray(o);break;case"map_kd":r("map",o);break;case"map_ks":r("specularMap",o);break;case"map_bump":case"bump":r("bumpMap",o);break;case"ns":s.shininess=parseFloat(o);break;case"d":o<1&&(s.opacity=o,s.transparent=!0);break;case"Tr":o>0&&(s.opacity=1-o,s.transparent=!0)}}return this.materials[e]=new THREE.MeshPhongMaterial(s),this.materials[e]},getTextureParams:function(e,t){var r,a={scale:new THREE.Vector2(1,1),offset:new THREE.Vector2(0,0)},i=e.split(/\s+/);return r=i.indexOf("-bm"),r>=0&&(t.bumpScale=parseFloat(i[r+1]),i.splice(r,2)),r=i.indexOf("-s"),r>=0&&(a.scale.set(parseFloat(i[r+1]),parseFloat(i[r+2])),i.splice(r,4)),r=i.indexOf("-o"),r>=0&&(a.offset.set(parseFloat(i[r+1]),parseFloat(i[r+2])),i.splice(r,4)),a.url=i.join(" ").trim(),a},loadTexture:function(e,t,r,a,i){var s;if(altspace&&altspace.inClient)s=new THREE.Texture({src:e});else{var n=THREE.Loader.Handlers.get(e),o=void 0!==this.manager?this.manager:THREE.DefaultLoadingManager;null===n&&(n=new THREE.TextureLoader(o)),n.setCrossOrigin&&n.setCrossOrigin(this.crossOrigin),s=n.load(e,r,a,i)}return void 0!==t&&(s.mapping=t),s}},THREE.OBJLoader=function(e){this.manager=void 0!==e?e:THREE.DefaultLoadingManager,this.materials=null,this.regexp={vertex_pattern:/^v\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,normal_pattern:/^vn\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,uv_pattern:/^vt\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,face_vertex:/^f\s+(-?\d+)\s+(-?\d+)\s+(-?\d+)(?:\s+(-?\d+))?/,face_vertex_uv:/^f\s+(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)(?:\s+(-?\d+)\/(-?\d+))?/,face_vertex_uv_normal:/^f\s+(-?\d+)\/(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\/(-?\d+)(?:\s+(-?\d+)\/(-?\d+)\/(-?\d+))?/,face_vertex_normal:/^f\s+(-?\d+)\/\/(-?\d+)\s+(-?\d+)\/\/(-?\d+)\s+(-?\d+)\/\/(-?\d+)(?:\s+(-?\d+)\/\/(-?\d+))?/,object_pattern:/^[og]\s*(.+)?/,smoothing_pattern:/^s\s+(\d+|on|off)/,material_library_pattern:/^mtllib /,material_use_pattern:/^usemtl /}},THREE.OBJLoader.prototype={constructor:THREE.OBJLoader,load:function(e,t,r,a){var i=this,s=new THREE.FileLoader(i.manager);s.setPath(this.path),s.load(e,function(e){t(i.parse(e))},r,a)},setPath:function(e){this.path=e},setMaterials:function(e){this.materials=e},_createParserState:function(){var e={objects:[],object:{},vertices:[],normals:[],uvs:[],materialLibraries:[],startObject:function(e,t){if(this.object&&this.object.fromDeclaration===!1)return this.object.name=e,void(this.object.fromDeclaration=t!==!1);var r=this.object&&"function"==typeof this.object.currentMaterial?this.object.currentMaterial():void 0;if(this.object&&"function"==typeof this.object._finalize&&this.object._finalize(!0),this.object={name:e||"",fromDeclaration:t!==!1,geometry:{vertices:[],normals:[],uvs:[]},materials:[],smooth:!0,startMaterial:function(e,t){var r=this._finalize(!1);r&&(r.inherited||r.groupCount<=0)&&this.materials.splice(r.index,1);var a={index:this.materials.length,name:e||"",mtllib:Array.isArray(t)&&t.length>0?t[t.length-1]:"",smooth:void 0!==r?r.smooth:this.smooth,groupStart:void 0!==r?r.groupEnd:0,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(e){var t={index:"number"==typeof e?e:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return t.clone=this.clone.bind(t),t}};return this.materials.push(a),a},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(e){var t=this.currentMaterial();if(t&&t.groupEnd===-1&&(t.groupEnd=this.geometry.vertices.length/3,t.groupCount=t.groupEnd-t.groupStart,t.inherited=!1),e&&this.materials.length>1)for(var r=this.materials.length-1;r>=0;r--)this.materials[r].groupCount<=0&&this.materials.splice(r,1);return e&&0===this.materials.length&&this.materials.push({name:"",smooth:this.smooth}),t}},r&&r.name&&"function"==typeof r.clone){var a=r.clone(0);a.inherited=!0,this.object.materials.push(a)}this.objects.push(this.object)},finalize:function(){this.object&&"function"==typeof this.object._finalize&&this.object._finalize(!0)},parseVertexIndex:function(e,t){var r=parseInt(e,10);return 3*(r>=0?r-1:r+t/3)},parseNormalIndex:function(e,t){var r=parseInt(e,10);return 3*(r>=0?r-1:r+t/3)},parseUVIndex:function(e,t){var r=parseInt(e,10);return 2*(r>=0?r-1:r+t/2)},addVertex:function(e,t,r){var a=this.vertices,i=this.object.geometry.vertices;i.push(a[e+0]),i.push(a[e+1]),i.push(a[e+2]),i.push(a[t+0]),i.push(a[t+1]),i.push(a[t+2]),i.push(a[r+0]),i.push(a[r+1]),i.push(a[r+2])},addVertexLine:function(e){var t=this.vertices,r=this.object.geometry.vertices;r.push(t[e+0]),r.push(t[e+1]),r.push(t[e+2])},addNormal:function(e,t,r){var a=this.normals,i=this.object.geometry.normals;i.push(a[e+0]),i.push(a[e+1]),i.push(a[e+2]),i.push(a[t+0]),i.push(a[t+1]),i.push(a[t+2]),i.push(a[r+0]),i.push(a[r+1]),i.push(a[r+2])},addUV:function(e,t,r){var a=this.uvs,i=this.object.geometry.uvs;i.push(a[e+0]),i.push(a[e+1]),i.push(a[t+0]),i.push(a[t+1]),i.push(a[r+0]),i.push(a[r+1])},addUVLine:function(e){var t=this.uvs,r=this.object.geometry.uvs;r.push(t[e+0]),r.push(t[e+1])},addFace:function(e,t,r,a,i,s,n,o,l,c,h,u){var d,p=this.vertices.length,f=this.parseVertexIndex(e,p),m=this.parseVertexIndex(t,p),E=this.parseVertexIndex(r,p);if(void 0===a?this.addVertex(f,m,E):(d=this.parseVertexIndex(a,p),this.addVertex(f,m,d),this.addVertex(m,E,d)),void 0!==i){var v=this.uvs.length;f=this.parseUVIndex(i,v),m=this.parseUVIndex(s,v),E=this.parseUVIndex(n,v),void 0===a?this.addUV(f,m,E):(d=this.parseUVIndex(o,v),this.addUV(f,m,d),this.addUV(m,E,d))}if(void 0!==l){var g=this.normals.length;f=this.parseNormalIndex(l,g),m=l===c?f:this.parseNormalIndex(c,g),E=l===h?f:this.parseNormalIndex(h,g),void 0===a?this.addNormal(f,m,E):(d=this.parseNormalIndex(u,g),this.addNormal(f,m,d),this.addNormal(m,E,d))}},addLineGeometry:function(e,t){this.object.geometry.type="Line";for(var r=this.vertices.length,a=this.uvs.length,i=0,s=e.length;i0?A.addAttribute("normal",new THREE.BufferAttribute(new Float32Array(R.normals),3)):A.computeVertexNormals(),R.uvs.length>0&&A.addAttribute("uv",new THREE.BufferAttribute(new Float32Array(R.uvs),2));for(var N=[],M=0,H=w.length;M1){for(var M=0,H=w.length;M0?t:"visual_scene0"]}return null}function n(){var e=Fe.querySelectorAll("instance_kinematics_model")[0];if(e){var t=e.getAttribute("url").replace(/^#/,"");return ke[t.length>0?t:"kinematics_model0"]}return null}function o(){_e=[],l(Pe)}function l(e){var t=He.getChildById(e.colladaId,!0),r=null;if(t&&t.keys){r={fps:60,hierarchy:[{node:t,keys:t.keys,sids:t.sids}],node:e,name:"animation_"+e.name,length:0},_e.push(r);for(var a=0,i=t.keys.length;a=0){var n=t.invBindMatrices[i];a.invBindMatrix=n,a.skinningMatrix=new THREE.Matrix4,a.skinningMatrix.multiplyMatrices(a.world,n),a.animatrix=new THREE.Matrix4,a.animatrix.copy(a.localworld),a.weights=[];for(var s=0;ss.limits.max||r1)for(L=new THREE.MultiMaterial(b),s=0;s<_.faces.length;s++){var S=_.faces[s];S.materialIndex=T[S.daeMaterial]}void 0!==r?(m(_,r),_.morphTargets.length>0?(L.morphTargets=!0,L.skinning=!1):(L.morphTargets=!1,L.skinning=!0),H=new THREE.SkinnedMesh(_,L,!1),H.name="skin_"+je.length,je.push(H)):void 0!==a?(h(_,a),L.morphTargets=!0,H=new THREE.Mesh(_,L),H.name="morph_"+Ie.length,Ie.push(H)):H=_.isLineStrip===!0?new THREE.Line(_):new THREE.Mesh(_,L),n.add(H)}}for(i=0;it)break}return r}function R(e,t){for(var r=-1,a=0,i=e.length;a=t&&(r=a)}return r}function w(e,t,r,a){var i=A(e,a,r?r-1:0),s=x(e,a,r+1);if(i&&s){var n,o=(t.time-i.time)/(s.time-i.time),l=i.getTarget(a),c=s.getTarget(a).data,h=l.data;if("matrix"===l.type)n=h;else if(h.length){n=[];for(var u=0;u=0?r:r+e.length;r>=0;r--){var a=e[r];if(a.hasTarget(t))return a}return null}function N(){this.id="",this.init_from=""}function M(){this.id="",this.name="",this.type="",this.skin=null,this.morph=null}function H(){this.method=null,this.source=null,this.targets=null,this.weights=null}function L(){this.source="",this.bindShapeMatrix=null,this.invBindMatrices=[],this.joints=[],this.weights=[]}function _(){this.id="",this.name="",this.nodes=[],this.scene=new THREE.Group}function S(){this.id="",this.name="",this.sid="",this.nodes=[],this.controllers=[],this.transforms=[],this.geometries=[],this.channels=[],this.matrix=new THREE.Matrix4}function O(){this.sid="",this.type="",this.data=[],this.obj=null}function k(){this.url="",this.skeleton=[],this.instance_material=[]}function C(){this.symbol="",this.target=""}function I(){this.url="",this.instance_material=[]}function j(){this.id="",this.mesh=null}function F(e){this.geometry=e.id,this.primitives=[],this.vertices=null,this.geometry3js=null}function P(){this.material="",this.count=0,this.inputs=[],this.vcount=null,this.p=[],this.geometry=new THREE.Geometry}function U(){P.call(this),this.vcount=[]}function B(){P.call(this),this.vcount=1}function D(){P.call(this),this.vcount=3}function V(){this.source="",this.count=0,this.stride=0,this.params=[]}function G(){this.input={}}function Y(){this.semantic="",this.offset=0,this.source="",this.set=0}function q(e){this.id=e,this.type=null}function z(){this.id="",this.name="",this.instance_effect=null}function X(){this.color=new THREE.Color,this.color.setRGB(Math.random(),Math.random(),Math.random()),this.color.a=1,this.texture=null,this.texcoord=null,this.texOpts=null}function W(e,t){this.type=e,this.effect=t,this.material=null}function Z(e){this.effect=e,this.init_from=null,this.format=null}function K(e){this.effect=e,this.source=null,this.wrap_s=null,this.wrap_t=null,this.minfilter=null,this.magfilter=null,this.mipfilter=null}function J(){this.id="",this.name="",this.shader=null,this.surface={},this.sampler={}}function Q(){this.url=""}function $(){this.id="",this.name="",this.source={},this.sampler=[],this.channel=[]}function ee(e){this.animation=e,this.source="",this.target="",this.fullSid=null,this.sid=null,this.dotSyntax=null,this.arrSyntax=null,this.arrIndices=null,this.member=null}function te(e){this.id="",this.animation=e,this.inputs=[],this.input=null,this.output=null,this.strideOut=null,this.interpolation=null,this.startTime=null,this.endTime=null,this.duration=0}function re(e){this.targets=[],this.time=e}function ae(){this.id="",this.name="",this.technique=""}function ie(){this.url=""}function se(){this.id="",this.name="",this.technique=""}function ne(){this.url=""}function oe(){this.id="",this.name="",this.joints=[],this.links=[]}function le(){this.sid="",this.name="",this.axis=new THREE.Vector3,this.limits={min:0,max:0},this.type="",this.static=!1,this.zeroPosition=0,this.middlePosition=0}function ce(){this.sid="",this.name="",this.transforms=[],this.attachments=[]}function he(){this.joint="",this.transforms=[],this.links=[]}function ue(e){var t=e.getAttribute("id");return void 0!=Be[t]?Be[t]:(Be[t]=new q(t).parse(e),Be[t])}function de(e){for(var t=me(e),r=[],a=0,i=t.length;a0?Ee(e).split(/\s+/):[]}function Ee(e){return e.replace(/^\s+/,"").replace(/\s+$/,"")}function ve(e,t,r){return e.hasAttribute(t)?parseInt(e.getAttribute(t),10):r}function ge(e,t){if("string"!=typeof e||""===e)return"";if(/^(https?:)?\/\//i.test(e))return e;if(/^data:.*,.*$/i.test(e))return e;var r=new URL((t||"")+e,location.href.substring(0,location.href.lastIndexOf("/")+1));return r.toString()}function Te(e,t){var r=new THREE.ImageLoader;r.load(t,function(t){e.image=t,e.needsUpdate=!0})}function be(e,t){e.doubleSided=!1;var r=t.querySelectorAll("extra double_sided")[0];r&&r&&1===parseInt(r.textContent,10)&&(e.doubleSided=!0)}function ye(){if(Ke.convertUpAxis!==!0||Qe===Ke.upAxis)$e=null;else switch(Qe){case"X":$e="Y"===Ke.upAxis?"XtoY":"XtoZ";break;case"Y":$e="X"===Ke.upAxis?"YtoX":"YtoZ";break;case"Z":$e="X"===Ke.upAxis?"ZtoX":"ZtoY"}}function Re(e,t){if(Ke.convertUpAxis===!0&&Qe!==Ke.upAxis)switch($e){case"XtoY":var r=e[0];e[0]=t*e[1],e[1]=r;break;case"XtoZ":var r=e[2];e[2]=e[1],e[1]=e[0],e[0]=r;break;case"YtoX":var r=e[0];e[0]=e[1],e[1]=t*r;break;case"YtoZ":var r=e[1];e[1]=t*e[2],e[2]=r;break;case"ZtoX":var r=e[0];e[0]=e[1],e[1]=e[2],e[2]=r;break;case"ZtoY":var r=e[1];e[1]=e[2],e[2]=t*r}}function we(e,t){if(Ke.convertUpAxis!==!0||Qe===Ke.upAxis)return t;switch(e){case"X":t="XtoY"===$e?t*-1:t;break;case"Y":t="YtoZ"===$e||"YtoX"===$e?t*-1:t;break;case"Z":t="ZtoY"===$e?t*-1:t}return t}function xe(e,t){var r=[e[t],e[t+1],e[t+2]];return Re(r,-1),new THREE.Vector3(r[0],r[1],r[2])}function Ae(e){if(Ke.convertUpAxis){var t=[e[0],e[4],e[8]];Re(t,-1),e[0]=t[0],e[4]=t[1],e[8]=t[2],t=[e[1],e[5],e[9]],Re(t,-1),e[1]=t[0],e[5]=t[1],e[9]=t[2],t=[e[2],e[6],e[10]],Re(t,-1),e[2]=t[0],e[6]=t[1],e[10]=t[2],t=[e[0],e[1],e[2]],Re(t,-1),e[0]=t[0],e[1]=t[1],e[2]=t[2],t=[e[4],e[5],e[6]],Re(t,-1),e[4]=t[0],e[5]=t[1],e[6]=t[2],t=[e[8],e[9],e[10]],Re(t,-1),e[8]=t[0],e[9]=t[1],e[10]=t[2],t=[e[3],e[7],e[11]],Re(t,-1),e[3]=t[0],e[7]=t[1],e[11]=t[2]}return(new THREE.Matrix4).set(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15])}function Ne(e){if(e>-1&&e<3){var t=["X","Y","Z"],r={X:0,Y:1,Z:2};e=Me(t[e]),e=r[e]}return e}function Me(e){if(Ke.convertUpAxis)switch(e){case"X":switch($e){case"XtoY":case"XtoZ":case"YtoX":e="Y";break;case"ZtoX":e="Z"}break;case"Y":switch($e){case"XtoY":case"YtoX":case"ZtoX":e="X";break;case"XtoZ":case"YtoZ":case"ZtoY":e="Z"}break;case"Z":switch($e){case"XtoZ":e="X";break;case"YtoZ":case"ZtoX":case"ZtoY":e="Y"}}return e}var He,Le,_e,Se,Oe,ke,Ce,Ie,je,Fe=null,Pe=null,Ue=null,Be={},De={},Ve={},Ge={},Ye={},qe={},ze={},Xe={},We={},Ze=THREE.SmoothShading,Ke={centerGeometry:!1,convertUpAxis:!1,subdivideFaces:!0,upAxis:"Y",defaultEnvMap:null},Je=1,Qe="Y",$e=null;return N.prototype.parse=function(e){this.id=e.getAttribute("id");for(var t=0;t=0,l=n.indexOf("(")>=0;if(o)s=n.split("."),n=s.shift(),a=s.shift();else if(l){r=n.split("("),n=r.shift();for(var c=0;c4&&Ke.subdivideFaces){var L=R.length?R:new THREE.Color;for(a=1;a4?[A[0],A[w+1],A[w+2]]:4===d?0===w?[A[0],A[1],A[3]]:[A[1].clone(),A[2],A[3].clone()]:[A[0],A[1],A[2]],void 0===t.faceVertexUvs[a]&&(t.faceVertexUvs[a]=[]),t.faceVertexUvs[a].push(N);else console.log("dropped face with vcount "+d+" for geometry with id: "+t.id);g+=p*d}},P.prototype.setVertices=function(e){for(var t=0;t0&&(this[r.nodeName]=parseFloat(i[0].textContent))}}return this.create(),this},W.prototype.create=function(){var e={},t=!1;if(void 0!==this.transparency&&void 0!==this.transparent){var r=(this.transparent,(this.transparent.color.r+this.transparent.color.g+this.transparent.color.b)/3*this.transparency);r>0&&(t=!0,e.transparent=!0,e.opacity=1-r)}var a={diffuse:"map",ambient:"lightMap",specular:"specularMap",emission:"emissionMap",bump:"bumpMap",normal:"normalMap"};for(var i in this)switch(i){case"ambient":case"emission":case"diffuse":case"specular":case"bump":case"normal":var s=this[i];if(s instanceof X)if(s.isTexture()){var n=s.texture,o=this.effect.sampler[n];if(void 0!==o&&void 0!==o.source){var l=this.effect.surface[o.source];if(void 0!==l){var c=De[l.init_from];if(c){var h,u=Ce+c.init_from;if(altspace&&altspace.inClient)h=new THREE.Texture({src:ge(u)});else{var d=THREE.Loader.Handlers.get(u);null!==d?h=d.load(u):(h=new THREE.Texture,Te(h,u))}"MIRROR"===o.wrap_s?h.wrapS=THREE.MirroredRepeatWrapping:"WRAP"===o.wrap_s||s.texOpts.wrapU?h.wrapS=THREE.RepeatWrapping:h.wrapS=THREE.ClampToEdgeWrapping,"MIRROR"===o.wrap_t?h.wrapT=THREE.MirroredRepeatWrapping:"WRAP"===o.wrap_t||s.texOpts.wrapV?h.wrapT=THREE.RepeatWrapping:h.wrapT=THREE.ClampToEdgeWrapping,h.offset.x=s.texOpts.offsetU,h.offset.y=s.texOpts.offsetV,h.repeat.x=s.texOpts.repeatU,h.repeat.y=s.texOpts.repeatV,e[a[i]]=h,"emission"===i&&(e.emissive=16777215)}}}}else"diffuse"!==i&&t||("emission"===i?e.emissive=s.color.getHex():e[i]=s.color.getHex());break;case"shininess":e[i]=this[i];break;case"reflectivity":e[i]=this[i],e[i]>0&&(e.envMap=Ke.defaultEnvMap),e.combine=THREE.MixOperation;break;case"index_of_refraction":e.refractionRatio=this[i],1!==this[i]&&(e.envMap=Ke.defaultEnvMap);break;case"transparency":}switch(e.shading=Ze,e.side=this.effect.doubleSided?THREE.DoubleSide:THREE.FrontSide,void 0!==e.diffuse&&(e.color=e.diffuse,delete e.diffuse),this.type){case"constant":void 0!=e.emissive&&(e.color=e.emissive),this.material=new THREE.MeshBasicMaterial(e);break;case"phong":case"blinn":this.material=new THREE.MeshPhongMaterial(e);break;case"lambert":default:this.material=new THREE.MeshLambertMaterial(e)}return this.material},Z.prototype.parse=function(e){for(var t=0;t=0,i=r.indexOf("(")>=0;if(a)t=r.split("."),this.sid=t.shift(),this.member=t.shift();else if(i){var s=r.split("(");this.sid=s.shift();for(var n=0;n1){a=[],t*=this.strideOut;for(var i=0;i1&&(o=1),c.length){i=[];for(var h=0;h=this.limits.max&&(this.static=!0),this.middlePosition=(this.limits.min+this.limits.max)/2,this},ce.prototype.parse=function(e){this.sid=e.getAttribute("sid"),this.name=e.getAttribute("name"),this.transforms=[],this.attachments=[];for(var t=0;t=0&&(n[u.KHR_MATERIALS_COMMON]=new a(c)),console.time("GLTFLoader");var d=new h(c,n,{path:r||this.path,crossOrigin:this.crossOrigin});d.parse(function(e,r,a,i){console.log("------------ UltimateLoader ---------------"),console.timeEnd("GLTFLoader");var s={scene:e,scenes:r,cameras:a,animations:i};t(s)})}},e.Shaders={update:function(){console.warn("THREE.GLTFLoader.Shaders has been deprecated, and now updates automatically.")}},r.prototype.update=function(e,t){var r=this.boundUniforms;for(var a in r){var i=r[a];switch(i.semantic){case"MODELVIEW":var s=i.uniform.value;s.multiplyMatrices(t.matrixWorldInverse,i.sourceNode.matrixWorld);break;case"MODELVIEWINVERSETRANSPOSE":var n=i.uniform.value;this._m4.multiplyMatrices(t.matrixWorldInverse,i.sourceNode.matrixWorld),n.getNormalMatrix(this._m4);break;case"PROJECTION":var s=i.uniform.value;s.copy(t.projectionMatrix);break;case"JOINTMATRIX":for(var o=i.uniform.value,l=0;l0?new Uint8Array(g.buffer,T,e):new Uint8Array);return T+=Uint8Array.BYTES_PER_ELEMENT*e,t}function n(e){if(T%Uint16Array.BYTES_PER_ELEMENT===0){var t=new Uint16Array(g.buffer,T,e);return T+=Uint16Array.BYTES_PER_ELEMENT*e,t}for(var t=new Uint16Array(e),r=0;r0?THREE.SmoothShading:THREE.FlatShading,this.debug&&console.log("Group Material",$,C)}var ee=new THREE.Mesh(Q,C);W&&(ee.name=W),P.add(ee)}}}}return this.performanceTimer&&console.timeEnd("BOMLoader"),y}},THREE.BOMLoaderUtil=THREE.BOMLoaderUtil||{},THREE.BOMLoaderUtil.multiload=function(e,t){function r(e,r){var s=new THREE.BOMLoader;s.setTexturePath(r.url.split("/").slice(0,-1).join("/")+"/"),void 0!==r.debug&&s.setDebug(r.debug),void 0!==r.timer&&s.setPerfTimer(r.timer),void 0!==r.crossOrigin&&s.setCrossOrigin(r.crossOrigin),void 0!==r.responseType&&s.setResponseType(r.responseType),s.load(r.url,function(s){r.object=s,i[e]=r,--a<=0&&t(i)})}e=e.constructor===Array?e:[e];for(var a=e.length,i=[],s=0;s