aframe-extras
Advanced tools
Comparing version 3.9.1 to 3.10.0
@@ -1,2 +0,2 @@ | ||
!function e(t,r,i){function n(s,a){if(!r[s]){if(!t[s]){var c="function"==typeof require&&require;if(!a&&c)return c(s,!0);if(o)return o(s,!0);var h=new Error("Cannot find module '"+s+"'");throw h.code="MODULE_NOT_FOUND",h}var l=r[s]={exports:{}};t[s][0].call(l.exports,function(e){var r=t[s][1][e];return n(r||e)},l,l.exports,e,t,r,i)}return r[s].exports}for(var o="function"==typeof require&&require,s=0;s<i.length;s++)n(i[s]);return n}({1:[function(e,t,r){e("./src/loaders").registerAll()},{"./src/loaders":8}],2:[function(e,t,r){!function(){function e(){}function r(){}function i(){this.skinIndices=[],this.skinWeights=[],this.matrices=[]}function n(){this.hierarchy=[]}function o(){this.geometries={}}function s(){this.node=null,this.name=null,this.id=null,this.vertices=[],this.indices=[],this.normals=[],this.uvs=[],this.bones=[]}function a(){this.uv=null,this.map=null,this.ref=null,this.node=null,this.index=null}function c(){this.normal=null,this.map=null,this.ref=null,this.node=null,this.index=null}function h(){this.indexBuffer=[]}function l(){this.version=null,this.id=null,this.internalId=null,this.times=null,this.values=null,this.attrFlag=null,this.attrData=null}function u(){this.id=null,this.attr=null,this.attrX=!1,this.attrY=!1,this.attrZ=!1,this.internalId=null,this.containerInternalId=null,this.containerBoneId=null,this.curveIdx=null,this.curves={}}function d(){this.curves={},this.length=0,this.fps=30,this.frames=0}function p(){this.textures={}}function m(){this.fileName="",this.name="",this.id=null,this.parentIds=[]}function f(){this.materials={},this.perGeoMap={}}function v(){this.fileName="",this.name="",this.id=null,this.parentIds=[]}function y(e,t,r){for(var i=[],n=0;n<t.length;++n)for(var o=0;o<r;++o)i.push(e[t[n]*r+o]);return i}function g(e,t,r,i){for(var n=[],o=0,s=0;s<t.length;++s){n[t[s]]=[];for(var a=0;a<i;++a)n[t[s]][a]=e[o+a];o+=i}for(var c=[],h=0;h<n.length;++h)if(void 0!==n[h])for(var l=0;l<i;++l)void 0!==n[h][l]&&c.push(n[h][l]);return c}function _(e,t,r){for(var i={},n=[],o=0,s=0;s<t.length;++s)if(!(t[s]in i)){i[t[s]]={};for(var a=0;a<r;++a)i[t[s]][a]=e[s*r+a];o=o<t[s]?t[s]:o}try{for(s=0;s<=o;s++)for(var c=0;c<r;c++)n.push(i[s][c])}catch(e){}return n}function E(e){return e/46186158e3}function b(e){return e*Math.PI/180}function x(e,t,r){var i=new THREE.Euler(e,t,r,"ZYX"),n=new THREE.Quaternion;return n.setFromEuler(i),n}function T(e){return e.split(",").map(function(e){return parseInt(e)})}function w(e){return e.split(",").map(function(e){return parseFloat(e)})}function N(e){return e.split(",").map(function(e){return b(parseFloat(e))})}function I(e){var t=w(e);return(new THREE.Matrix4).fromArray(t)}t.exports=THREE.FBXLoader=function(e){THREE.Loader.call(this),this.manager=void 0!==e?e:THREE.DefaultLoadingManager,this.textureLoader=null,this.textureBasePath=null},THREE.FBXLoader.prototype=Object.create(THREE.Loader.prototype),THREE.FBXLoader.prototype.constructor=THREE.FBXLoader,Object.assign(THREE.FBXLoader.prototype,{load:function(e,t,r,i){var n=this;new THREE.XHRLoader(n.manager).load(e,function(r){n.isFbxFormatASCII(r)?n.isFbxVersionSupported(r)?(n.textureBasePath=n.extractUrlBase(e),t(n.parse(r))):console.warn("FBXLoader: !!! FBX Version below 7 not supported !!!"):console.warn("FBXLoader: !!! FBX Binary format not supported !!!")},r,i)},setCrossOrigin:function(e){this.crossOrigin=e},isFbxFormatASCII:function(e){for(var t=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"],r=0,i=0;i<t.length;++i){if(function(t){var i=e[t-1];return e=e.slice(r+t),r++,i}(1)==t[i])return!1}return!0},isFbxVersionSupported:function(e){var t=/FBXVersion: (\d+)/,r=e.match(t);if(r){var i=parseInt(r[1]);return console.log("FBXLoader: FBX version "+i),i>=7e3}return!1},parse:function(e){var t=this;console.time("FBXLoader"),console.time("FBXLoader: TextParser");var s=(new r).parse(e);console.timeEnd("FBXLoader: TextParser"),console.time("FBXLoader: ObjectParser"),t.hierarchy=(new n).parseHierarchy(s),t.weights=(new i).parse(s,t.hierarchy),t.animations=(new d).parse(s,t.hierarchy),t.textures=(new p).parse(s,t.hierarchy),t.materials=(new f).parse(s,t.hierarchy),t.geometries=(new o).parse(s,t.hierarchy),console.timeEnd("FBXLoader: ObjectParser"),this.texture_cache={},this.material_cache={},this.geometry_cache={},console.time("FBXLoader: MeshParser");var a=this.parseMeshes(s);console.timeEnd("FBXLoader: MeshParser");for(var c=new THREE.Group,h=0;h<a.length;++h)void 0!==a[h]&&c.add(a[h]);return console.timeEnd("FBXLoader"),c},getTexture:function(e){return e.id in this.texture_cache||(null===this.textureLoader&&(this.textureLoader=new THREE.TextureLoader),this.texture_cache[e.id]=this.textureLoader.load(this.textureBasePath+"/"+e.fileName)),this.texture_cache[e.id]},getMaterial:function(e,t){if(!(e.id in this.material_cache)){var r;switch(e.type){case"phong":r=new THREE.MeshPhongMaterial;break;case"lambert":r=new THREE.MeshLambertMaterial;break;default:console.warn("No implementation given for material type "+e.type+" in FBXLoader.js. Defaulting to basic material"),r=new THREE.MeshBasicMaterial({color:3342591})}for(var i=t.searchConnectionChildren(e.id),n=0;n<i.length;++n){var o=t.searchConnectionType(i[n],e.id);switch(o){case' "AmbientColor':break;case' "DiffuseColor':e.parameters.map=this.getTexture(this.textures.textures[i[n]]);break;default:console.warn("Unknown texture application of type "+o+", skipping texture")}}r.setValues(e.parameters),this.material_cache[e.id]=r}return this.material_cache[e.id]},getGeometry:function(e){if(!(e.id in this.geometry_cache)){var t=new THREE.BufferGeometry;if(t.name=e.name,t.addAttribute("position",new THREE.BufferAttribute(new Float32Array(e.vertices),3)),void 0!==e.normals&&e.normals.length>0&&t.addAttribute("normal",new THREE.BufferAttribute(new Float32Array(e.normals),3)),void 0!==e.uvs&&e.uvs.length>0&&t.addAttribute("uv",new THREE.BufferAttribute(new Float32Array(e.uvs),2)),void 0!==e.indices&&e.indices.length>0&&(e.indices.length>65535?t.setIndex(new THREE.BufferAttribute(new Uint32Array(e.indices),1)):t.setIndex(new THREE.BufferAttribute(new Uint16Array(e.indices),1))),t.verticesNeedUpdate=!0,t.computeBoundingSphere(),t.computeBoundingBox(),e.materialIndices.length>1){t.groups=[];for(var r=0,i=-1;r<e.materialIndices.length;++r)e.materialIndices[r]!==i&&(t.groups.push({start:3*r,count:0,materialIndex:e.materialIndices[r]}),i=e.materialIndices[r]),t.groups[t.groups.length-1].count+=3}this.geometry_cache[e.id]=(new THREE.Geometry).fromBufferGeometry(t),this.geometry_cache[e.id].bones=e.bones,this.geometry_cache[e.id].skinIndices=this.weights.skinIndices,this.geometry_cache[e.id].skinWeights=this.weights.skinWeights}return this.geometry_cache[e.id]},parseMeshes:function(e){var t=e.Objects.subNodes.Model,r=[];for(var i in t)"Mesh"===t[i].attrType&&r.push(this.parseMesh(t[i],e));return r},parseMesh:function(e,t){for(var r,i,n,o=t.Objects.subNodes.Geometry,s=t.Objects.subNodes.Material,a=t.searchConnectionChildren(e.id),c=[],h=0;h<a.length;++h)a[h]in o?r=this.getGeometry(this.geometries.geometries[a[h]]):a[h]in s&&c.push(this.getMaterial(this.materials.materials[a[h]],t));if(i=c.length>1?new THREE.MultiMaterial(c):c[0],void 0!==r.bones&&void 0!==r.skinWeights){if(i instanceof THREE.MultiMaterial)for(var h=0;h<i.materials.length;++h)i.materials[h].skinning=!0;else i.skinning=!0;n=new THREE.SkinnedMesh(r,i)}else n=new THREE.Mesh(r,i);return void 0!==this.animations&&this.addAnimation(n,this.weights.matrices,this.animations),n},addAnimation:function(e,t,r){function i(e,t){if(void 0===e)return!1;var r;switch(t){case"S":if(!e.S)return!1;r=e.S;break;case"R":if(!e.R)return!1;r=e.R;break;case"T":if(!e.T)return!1;r=e.T}return void 0!==r.curves.x&&(void 0!==r.curves.y&&void 0!==r.curves.z)}function n(e,t){var r=o(e.curves.x,t),i=o(e.curves.y,t),n=o(e.curves.z,t);return r&&i&&n}function o(e,t){return void 0!==e.values[t]}for(var s in r.stacks){for(var a={name:r.stacks[s].name,fps:30,length:r.stacks[s].length,hierarchy:[]},c=0;c<e.geometry.bones.length;++c){var h=e.geometry.bones[c].name;h=h.replace(/.*:/,""),a.hierarchy.push({parent:e.geometry.bones[c].parent,name:h,keys:[]})}for(var l=e.geometry.bones,u=0;u<r.stacks[s].frames;u++)for(c=0;c<l.length;c++)for(var d=l[c],p=r.stacks[s].layers[0][c],m=0;m<a.hierarchy.length;m++)a.hierarchy[m].name===d.name&&a.hierarchy[m].keys.push(function(e,t){var o={};if(o.time=u/r.fps,o.pos=t.pos,o.rot=t.rotq,o.scl=t.scl,void 0===e)return o;try{if(i(e,"T")&&n(e.T,u)){var s=new THREE.Vector3(e.T.curves.x.values[u],e.T.curves.y.values[u],e.T.curves.z.values[u]);o.pos=[s.x,s.y,s.z]}if(i(e,"R")&&n(e.R,u)){var a=b(e.R.curves.x.values[u]),c=b(e.R.curves.y.values[u]),h=b(e.R.curves.z.values[u]),l=new THREE.Vector3(a,c,h),d=x(l.x,l.y,l.z);o.rot=[d.x,d.y,d.z,d.w]}if(i(e,"S")&&n(e.S,u)){var p=new THREE.Vector3(e.S.curves.x.values[u],e.S.curves.y.values[u],e.S.curves.z.values[u]);o.scl=[p.x,p.y,p.z]}}catch(e){console.log(t),console.log(e)}return o}(p,d));void 0===e.geometry.animations&&(e.geometry.animations=[]),e.geometry.animations.push(THREE.AnimationClip.parseAnimation(a,e.geometry.bones))}},loadFile:function(e,t,r,i,n){var o=new THREE.XHRLoader(this.manager);return o.setResponseType(n),o.load(e,t,r,i)},loadFileAsBuffer:function(e,t,r,i){this.loadFile(e,t,r,i,"arraybuffer")},loadFileAsText:function(e,t,r,i){this.loadFile(e,t,r,i,"text")}}),Object.assign(e.prototype,{add:function(e,t){this[e]=t},searchConnectionParent:function(e){if(void 0===this.__cache_search_connection_parent&&(this.__cache_search_connection_parent=[]),void 0!==this.__cache_search_connection_parent[e])return this.__cache_search_connection_parent[e];this.__cache_search_connection_parent[e]=[];for(var t=this.Connections.properties.connections,r=[],i=0;i<t.length;++i)if(t[i][0]==e){var n=0===t[i][1]?-1:t[i][1];r.push(n)}return r.length>0?(this.__cache_search_connection_parent[e]=this.__cache_search_connection_parent[e].concat(r),r):(this.__cache_search_connection_parent[e]=[-1],[-1])},searchConnectionChildren:function(e){if(void 0===this.__cache_search_connection_children&&(this.__cache_search_connection_children=[]),void 0!==this.__cache_search_connection_children[e])return this.__cache_search_connection_children[e];this.__cache_search_connection_children[e]=[];for(var t=this.Connections.properties.connections,r=[],i=0;i<t.length;++i)t[i][1]==e&&r.push(0===t[i][0]?-1:t[i][0]);return r.length>0?(this.__cache_search_connection_children[e]=this.__cache_search_connection_children[e].concat(r),r):(this.__cache_search_connection_children[e]=[],[])},searchConnectionType:function(e,t){var r=e+","+t;if(void 0===this.__cache_search_connection_type&&(this.__cache_search_connection_type={}),void 0!==this.__cache_search_connection_type[r])return this.__cache_search_connection_type[r];this.__cache_search_connection_type[r]="";for(var i=this.Connections.properties.connections,n=0;n<i.length;++n)if(i[n][0]==e&&i[n][1]==t)return this.__cache_search_connection_type[r]=i[n][2],i[n][2];return this.__cache_search_connection_type[e]=null,null}}),Object.assign(r.prototype,{getPrevNode:function(){return this.nodeStack[this.currentIndent-2]},getCurrentNode:function(){return this.nodeStack[this.currentIndent-1]},getCurrentProp:function(){return this.currentProp},pushStack:function(e){this.nodeStack.push(e),this.currentIndent+=1},popStack:function(){this.nodeStack.pop(),this.currentIndent-=1},setCurrentProp:function(e,t){this.currentProp=e,this.currentPropName=t},parse:function(t){this.currentIndent=0,this.allNodes=new e,this.nodeStack=[],this.currentProp=[],this.currentPropName="";var r=t.split("\n");for(var i in r){var n=r[i];if(!n.match(/^[\s\t]*;/)&&!n.match(/^[\s\t]*$/)){var o=new RegExp("^\\t{"+this.currentIndent+"}(\\w+):(.*){",""),s=n.match(o);if(s){var a=s[1].trim().replace(/^"/,"").replace(/"$/,""),c=s[2].split(",").map(function(e){return e.trim().replace(/^"/,"").replace(/"$/,"")});this.parseNodeBegin(n,a,c||null)}else{var h=new RegExp("^\\t{"+this.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),s=n.match(h);if(s){var l=s[1].replace(/^"/,"").replace(/"$/,"").trim(),u=s[2].replace(/^"/,"").replace(/"$/,"").trim();this.parseNodeProperty(n,l,u)}else{var d=new RegExp("^\\t{"+(this.currentIndent-1)+"}}");n.match(d)?this.nodeEnd():n.match(/^[^\s\t}]/)&&this.parseNodePropertyContinued(n)}}}}return this.allNodes},parseNodeBegin:function(e,t,r){var i={name:t,properties:{},subNodes:{}},n=this.parseNodeAttr(r),o=this.getCurrentNode();if(0===this.currentIndent)this.allNodes.add(t,i);else if(t in o.subNodes){var s=o.subNodes[t];this.isFlattenNode(o.subNodes[t])&&(""===n.id?(o.subNodes[t]=[],o.subNodes[t].push(s)):(o.subNodes[t]={},o.subNodes[t][s.id]=s)),""===n.id?o.subNodes[t].push(i):o.subNodes[t][n.id]=i}else"number"==typeof n.id||n.id.match(/^\d+$/)?(o.subNodes[t]={},o.subNodes[t][n.id]=i):o.subNodes[t]=i;r&&(i.id=n.id,i.attrName=n.name,i.attrType=n.type),this.pushStack(i)},parseNodeAttr:function(e){var t=e[0];""!==e[0]&&(t=parseInt(e[0]),isNaN(t)&&(t=e[0]));var r,i;return e.length>1&&(r=e[1].replace(/^(\w+)::/,""),i=e[2]),{id:t,name:r||"",type:i||""}},parseNodeProperty:function(e,t,r){var i=this.getCurrentNode(),n=i.name;if(void 0!==n){if(n.match(/Properties(\d)+/))return void this.parseNodeSpecialProperty(e,t,r)}if("C"==t){var o=r.split(",").slice(1),s=parseInt(o[0]),a=parseInt(o[1]),c=r.split(",").slice(3);t="connections",r=[s,a],r=r.concat(c),void 0===i.properties[t]&&(i.properties[t]=[])}if("Node"==t){var h=parseInt(r);i.properties.id=h,i.id=h}t in i.properties?Array.isArray(i.properties[t])?i.properties[t].push(r):i.properties[t]+=r:Array.isArray(i.properties[t])?i.properties[t].push(r):i.properties[t]=r,this.setCurrentProp(i.properties,t)},parseNodePropertyContinued:function(e){this.currentProp[this.currentPropName]+=e},parseNodeSpecialProperty:function(e,t,r){var i=r.split('",').map(function(e){return e.trim().replace(/^\"/,"").replace(/\s/,"_")}),n=i[0],o=i[1],s=i[2],a=i[3],c=i[4];switch(o){case"int":c=parseInt(c);break;case"double":c=parseFloat(c);break;case"ColorRGB":case"Vector3D":var h=c.split(",");c=new THREE.Vector3(h[0],h[1],h[2])}this.getPrevNode().properties[n]={type:o,type2:s,flag:a,value:c},this.setCurrentProp(this.getPrevNode().properties,n)},nodeEnd:function(){this.popStack()},isFlattenNode:function(e){return"subNodes"in e&&"properties"in e}}),i.prototype.parseCluster=function(e,t,r){var i=e.searchConnectionParent(t),n=T(r.subNodes.Indexes.properties.a),o=w(r.subNodes.Weights.properties.a),s=I(r.subNodes.Transform.properties.a),a=I(r.subNodes.TransformLink.properties.a);return{parent:i,id:parseInt(t),indices:n,weights:o,transform:s,transformlink:a,linkMode:r.properties.Mode}},i.prototype.parse=function(e,t){this.skinIndices=[],this.skinWeights=[],this.matrices=[];var r=e.Objects.subNodes.Deformer,i={};for(var n in r)if("Cluster"===r[n].attrType){if(!("Indexes"in r[n].subNodes))continue;var o=this.parseCluster(e,n,r[n]),s=e.searchConnectionChildren(o.id)[0];i[s]=o}for(var a=[],c=t.hierarchy,h=0;h<c.length;++h){var l=c[h].internalId;if(void 0!==i[l]){var u=i[l];this.matrices.push(u.transform);for(var d=0;d<u.indices.length;++d){void 0===a[u.indices[d]]&&(a[u.indices[d]]={},a[u.indices[d]].joint=[],a[u.indices[d]].weight=[]);var p=e.searchConnectionChildren(u.id);p.length>1&&console.warn("FBXLoader: node "+u.id+" have many weight kids: "+p),a[u.indices[d]].joint.push(t.getBoneIdfromInternalId(e,p[0])),a[u.indices[d]].weight.push(u.weights[d])}}else this.matrices.push(new THREE.Matrix4)}for(var m=0;m<a.length;m++)if(void 0!==a[m]){var f=new THREE.Vector4(a[m].joint[0]?a[m].joint[0]:0,a[m].joint[1]?a[m].joint[1]:0,a[m].joint[2]?a[m].joint[2]:0,a[m].joint[3]?a[m].joint[3]:0),v=new THREE.Vector4(a[m].weight[0]?a[m].weight[0]:0,a[m].weight[1]?a[m].weight[1]:0,a[m].weight[2]?a[m].weight[2]:0,a[m].weight[3]?a[m].weight[3]:0);this.skinIndices.push(f),this.skinWeights.push(v)}else this.skinIndices.push(new THREE.Vector4(0,0,0,0)),this.skinWeights.push(new THREE.Vector4(0,0,0,0));return this},n.prototype.parseHierarchy=function(e){var t=e.Objects,r=t.subNodes.Model,i=[];for(var n in r)void 0!==r[n].attrType&&i.push(r[n]);this.hierarchy=[];for(var o=0;o<i.length;++o){var s=i[o],a=e.searchConnectionParent(s.id)[0],c=[0,0,0],h=[0,0,0,1],l=[1,1,1];if("Lcl_Translation"in s.properties&&(c=w(s.properties.Lcl_Translation.value)),"Lcl_Rotation"in s.properties){h=N(s.properties.Lcl_Rotation.value);var u=new THREE.Quaternion;u.setFromEuler(new THREE.Euler(h[0],h[1],h[2],"ZYX")),h=[u.x,u.y,u.z,u.w]}"Lcl_Scaling"in s.properties&&(l=w(s.properties.Lcl_Scaling.value));var d=s.attrName;d=d.replace(/:/,""),d=d.replace(/_/,""),d=d.replace(/-/,""),this.hierarchy.push({parent:a,name:d,pos:c,rotq:h,scl:l,internalId:s.id})}return this.reindexParentId(),this.restoreBindPose(e),this},n.prototype.reindexParentId=function(){for(var e=0;e<this.hierarchy.length;e++)for(var t=0;t<this.hierarchy.length;++t)if(this.hierarchy[e].parent==this.hierarchy[t].internalId){this.hierarchy[e].parent=t;break}},n.prototype.restoreBindPose=function(e){var t=e.Objects.subNodes.Pose;if(void 0!==t){for(var r in t)if("BindPose"===t[r].attrType){t=t[r];break}for(var i=t.subNodes.PoseNode,n={},o={},s=0;s<i.length;++s){var a=I(i[s].subNodes.Matrix.properties.a),c=I(i[s].subNodes.Matrix.properties.a);n[i[s].id]=a,o[i[s].id]=c}for(var h=0;h<this.hierarchy.length;++h){var l=this.hierarchy[h],u=l.internalId;if(void 0!==o[u]){for(var d,p=new THREE.Vector3(0,0,0),m=new THREE.Quaternion,f=new THREE.Vector3(1,1,1),v=e.searchConnectionParent(u),y=0;y<v.length;++y)if(this.isBoneNode(v[y])){d=v[y];break}if(void 0!==d&&void 0!==n[d]){var g=new THREE.Matrix4;g.getInverse(o[d]),g.multiply(n[u]),n[u]=g}n[u].decompose(p,m,f),l.pos=[p.x,p.y,p.z],l.rotq=[m.x,m.y,m.z,m.w],l.scl=[f.x,f.y,f.z]}}}},n.prototype.searchRealId=function(e){for(var t=0;t<this.hierarchy.length;t++)if(e==this.hierarchy[t].internalId)return t;return-1},n.prototype.getByInternalId=function(e){for(var t=0;t<this.hierarchy.length;t++)if(e==this.hierarchy[t].internalId)return this.hierarchy[t];return null},n.prototype.isBoneNode=function(e){for(var t=0;t<this.hierarchy.length;++t)if(e===this.hierarchy[t].internalId)return!0;return!1},n.prototype.getBoneIdfromInternalId=function(e,t){if(void 0===e.__cache_get_boneid_from_internalid&&(e.__cache_get_boneid_from_internalid=[]),void 0!==e.__cache_get_boneid_from_internalid[t])return e.__cache_get_boneid_from_internalid[t];for(var r=0;r<this.hierarchy.length;++r)if(this.hierarchy[r].internalId==t)return e.__cache_get_boneid_from_internalid[t]=r,r;return-1},Object.assign(o.prototype,{parse:function(e,t){if(!("Geometry"in e.Objects.subNodes))return this;for(var r in e.Objects.subNodes.Geometry)"Mesh"===e.Objects.subNodes.Geometry[r].attrType&&(this.geometries[r]=(new s).parse(e.Objects.subNodes.Geometry[r]),this.geometries[r].addBones(t.hierarchy));return this}}),s.prototype.parse=function(e){if(this.node=e,this.name=e.attrName,this.id=e.id,this.vertices=this.getVertices(),void 0===this.vertices)return void console.log("FBXLoader: Geometry.parse(): pass"+this.node.id);if(this.indices=this.getPolygonVertexIndices(),this.uvs=(new a).parse(this.node,this),this.normals=(new c).parse(this.node,this),this.materialIndices=(new h).parse(this.node),this.getPolygonTopologyMax()>3){var t=this.convertPolyIndicesToTri(this.indices,this.materialIndices,this.getPolygonTopologyArray());this.indices=t.res,this.materialIndices=t.materialIndices,this.polyIndices=t.polyIndices}return this},s.prototype.getVertices=function(){if(this.node.__cache_vertices)return this.node.__cache_vertices;if(void 0===this.node.subNodes.Vertices)return console.warn("this.node: "+this.node.attrName+"("+this.node.id+") does not have Vertices"),this.node.__cache_vertices=void 0,null;var e=this.node.subNodes.Vertices.properties.a,t=e.split(",").map(function(e){return parseFloat(e)});return this.node.__cache_vertices=t,this.node.__cache_vertices},s.prototype.getPolygonVertexIndices=function(){if(this.node.__cache_indices&&this.node.__cache_poly_topology_max)return this.node.__cache_indices;if(void 0===this.node.subNodes)return console.error("this.node.subNodes undefined"),void console.log(this.node);if(void 0===this.node.subNodes.PolygonVertexIndex)return console.warn("this.node: "+this.node.attrName+"("+this.node.id+") does not have PolygonVertexIndex "),void(this.node.__cache_indices=void 0);for(var e=this.node.subNodes.PolygonVertexIndex.properties.a,t=e.split(","),r=1,i=null,n=[],o=0;o<t.length;++o){var s=parseInt(t[o]);s<0?(r>i&&(i=r),t[o]=-1^s,n.push(r),r=1):(t[o]=s,r++)}return null===i&&(console.warn("FBXLoader: topology N not found: "+this.node.attrName),console.warn(this.node),i=3),this.node.__cache_poly_topology_max=i,this.node.__cache_poly_topology_arr=n,this.node.__cache_indices=t,this.node.__cache_indices},s.prototype.getPolygonTopologyMax=function(){return this.node.__cache_indices&&this.node.__cache_poly_topology_max?this.node.__cache_poly_topology_max:(this.getPolygonVertexIndices(this.node),this.node.__cache_poly_topology_max)},s.prototype.getPolygonTopologyArray=function(){return this.node.__cache_indices&&this.node.__cache_poly_topology_max?this.node.__cache_poly_topology_arr:(this.getPolygonVertexIndices(this.node),this.node.__cache_poly_topology_arr)},s.prototype.convertPolyIndicesToTri=function(e,t,r){for(var i=[],n=0,o=0,s=0,a=[];n<e.length;){s=r[o];for(var c=0;c<=s-3;c++)i.push(e[n]),i.push(e[n+(s-2-c)]),i.push(e[n+(s-1-c)]),a.push(o);o++,n+=s}var h=[t[0]];if(t.length>1)for(var n=0;n<a.length;++n)h[n]=t[a[n]];return{res:i,materialIndices:h,polyIndices:a}},s.prototype.addBones=function(e){this.bones=e},a.prototype.getUV=function(e){return this.node&&this.uv&&this.map&&this.ref?this.uv:this._parseText(e)},a.prototype.getMap=function(e){return this.node&&this.uv&&this.map&&this.ref?this.map:(this._parseText(e),this.map)},a.prototype.getRef=function(e){return this.node&&this.uv&&this.map&&this.ref?this.ref:(this._parseText(e),this.ref)},a.prototype.getIndex=function(e){return this.node&&this.uv&&this.map&&this.ref?this.index:(this._parseText(e),this.index)},a.prototype.getNode=function(e){return null!==this.node?this.node:(this.node=e.subNodes.LayerElementUV,this.node)},a.prototype._parseText=function(e){var t=this.getNode(e)[0];if(void 0===t)return[];var r=0;for(var i in t)i.match(/^\d+$/)&&r++;r>0&&(console.warn("multi uv not supported"),t=t[i]);var n=t.subNodes.UVIndex.properties.a,o=t.subNodes.UV.properties.a,s=t.properties.MappingInformationType,a=t.properties.ReferenceInformationType;return this.uv=w(o),this.index=T(n),this.map=s,this.ref=a,this.uv},a.prototype.parse=function(e,t){if("LayerElementUV"in e.subNodes){this.uvNode=this.getNode(e),this.uv=this.getUV(e);var r=this.getMap(e),i=this.getRef(e),n=this.getIndex(e),o=t.getPolygonTopologyArray();switch(r){case"ByPolygonVertex":switch(i){case"Direct":this.uv=this.parseUV_ByPolygonVertex_Direct(this.uv,n,o,2);break;case"IndexToDirect":this.uv=this.parseUV_ByPolygonVertex_IndexToDirect(this.uv,n)}this.uv=_(this.uv,t.getPolygonVertexIndices(e),2);break;case"ByPolygon":switch(i){case"Direct":this.uv=this.parseUV_ByPolygon_Direct();break;case"IndexToDirect":this.uv=this.parseUV_ByPolygon_IndexToDirect()}}return this.uv}},a.prototype.parseUV_ByPolygonVertex_Direct=function(e,t,r,i){return g(e,t,r,i)},a.prototype.parseUV_ByPolygonVertex_IndexToDirect=function(e,t){return y(e,t,2)},a.prototype.parseUV_ByPolygon_Direct=function(e){return console.warn("not implemented"),e},a.prototype.parseUV_ByPolygon_IndexToDirect=function(e){return console.warn("not implemented"),e},a.prototype.parseUV_ByVertex_Direct=function(e){return console.warn("not implemented"),e},c.prototype.getNormal=function(e){return this.node&&this.normal&&this.map&&this.ref?this.normal:(this._parseText(e),this.normal)},c.prototype.getMap=function(e){return this.node&&this.normal&&this.map&&this.ref?this.map:(this._parseText(e),this.map)},c.prototype.getRef=function(e){return this.node&&this.normal&&this.map&&this.ref?this.ref:(this._parseText(e),this.ref)},c.prototype.getNode=function(e){return this.node?this.node:(this.node=e.subNodes.LayerElementNormal,this.node)},c.prototype._parseText=function(e){var t=this.getNode(e)[0];if(void 0===t)return void console.warn("node: "+e.attrName+"("+e.id+") does not have LayerElementNormal");var r=t.properties.MappingInformationType,i=t.properties.ReferenceInformationType,n=t.subNodes.Normals.properties.a;this.normal=w(n),this.map=r,this.ref=i},c.prototype.parse=function(e,t){var r=this.getNormal(e),i=this.getMap(e),n=this.getRef(e),o=t.getPolygonVertexIndices(e),s=t.getPolygonTopologyArray(e);switch(i){case"ByPolygonVertex":switch(n){case"Direct":r=this.parseNormal_ByPolygonVertex_Direct(r,o,s,3);break;case"IndexToDirect":r=this.parseNormal_ByPolygonVertex_IndexToDirect()}break;case"ByPolygon":switch(n){case"Direct":r=this.parseNormal_ByPolygon_Direct();break;case"IndexToDirect":r=this.parseNormal_ByPolygon_IndexToDirect()}}return r},c.prototype.parseNormal_ByPolygonVertex_Direct=function(e,t,r,i){return g(e,t,r,i)},c.prototype.parseNormal_ByPolygonVertex_IndexToDirect=function(e){return console.warn("not implemented"),e},c.prototype.parseNormal_ByPolygon_Direct=function(e){return console.warn("not implemented"),e},c.prototype.parseNormal_ByPolygon_IndexToDirect=function(e){return console.warn("not implemented"),e},c.prototype.parseNormal_ByVertex_Direct=function(e){return console.warn("not implemented"),e},Object.assign(h.prototype,{parse:function(e){if("LayerElementMaterial"in e.subNodes){var t=e.subNodes.LayerElementMaterial[0],r=t.properties.MappingInformationType,i=t.properties.ReferenceInformationType,n=T(t.subNodes.Materials.properties.a);switch(r){case"ByPolygon":switch(i){case"IndexToDirect":this.indexBuffer=this.parse_ByPolygon_IndexToDirect(n);break;default:this.indexBuffer=[0]}break;default:this.indexBuffer=[0]}return this.indexBuffer}},parse_ByPolygon_IndexToDirect:function(e){return e}}),l.prototype.fromNode=function(e){return this.id=e.id,this.internalId=e.id,this.times=e.subNodes.KeyTime.properties.a,this.values=e.subNodes.KeyValueFloat.properties.a,this.attrFlag=e.subNodes.KeyAttrFlags.properties.a,this.attrData=e.subNodes.KeyAttrDataFloat.properties.a,this.times=w(this.times),this.values=w(this.values),this.attrData=w(this.attrData),this.attrFlag=T(this.attrFlag),this.times=this.times.map(function(e){return E(e)}),this},l.prototype.getLength=function(){return this.times[this.times.length-1]},u.prototype.fromNode=function(e,t,r){if(this.id=t.id,this.attr=t.attrName,this.internalId=t.id,!this.attr.match(/S|R|T/))return null;for(var i in t.properties)i.match(/X/)&&(this.attrX=!0),i.match(/Y/)&&(this.attrY=!0),i.match(/Z/)&&(this.attrZ=!0);this.containerIndices=e.searchConnectionParent(this.id),this.curveIdx=e.searchConnectionChildren(this.id);for(var n=this.containerIndices.length-1;n>=0;--n){var o=r.searchRealId(this.containerIndices[n]);if(o>=0&&(this.containerBoneId=o,this.containerId=this.containerIndices[n]),o>=0)break}return this},u.prototype.setCurve=function(e){this.curves.push(e)},d.prototype.parse=function(e,t){var r=e.Objects.subNodes.AnimationCurveNode,i=e.Objects.subNodes.AnimationCurve,n=e.Objects.subNodes.AnimationLayer,o=e.Objects.subNodes.AnimationStack,s=[];for(var a in r)if(a.match(/\d+/)){var c=(new u).fromNode(e,r[a],t);s.push(c)}for(var h={},d=0;d<s.length;++d)null!==s[d]&&(h[s[d].id]=s[d]);var p=[];for(a in i)if(a.match(/\d+/)){var m=(new l).fromNode(i[a]);p.push(m);var f=e.searchConnectionParent(m.id)[0],v=e.searchConnectionType(m.id,f);if(v.match(/X/))v="x";else if(v.match(/Y/))v="y";else{if(!v.match(/Z/))continue;v="z"}h[f].curves[v]=m}for(var y in h){var g=h[y].containerBoneId;void 0===this.curves[g]&&(this.curves[g]={T:null,R:null,S:null}),this.curves[g][h[y].attr]=h[y]}this.layers={};for(var a in n){for(var _=[],E=e.searchConnectionChildren(a),d=0;d<E.length;++d)h[E[d]]&&(void 0===_[h[E[d]].containerBoneId]&&(_[h[E[d]].containerBoneId]={T:null,R:null,S:null}),_[h[E[d]].containerBoneId][h[E[d]].attr]=h[E[d]]);this.layers[a]=_}this.stacks={};for(var a in o){for(var b=[],E=e.searchConnectionChildren(a),x=0,T=Number.MAX_VALUE,d=0;d<E.length;++d)if(E[d]in this.layers){b.push(this.layers[E[d]]);for(var w=0;w<this.layers[E[d]].length;++w){var _=this.layers[E[d]][w];_&&function(e){function t(e){e.x&&(x=e.x.getLength()>x?e.x.getLength():x,T=e.x.times[0]<T?e.x.times[0]:T),e.y&&(x=e.y.getLength()>x?e.y.getLength():x,T=e.y.times[0]<T?e.y.times[0]:T),e.z&&(x=e.z.getLength()>x?e.z.getLength():x,T=e.z.times[0]<T?e.z.times[0]:T)}e.R&&t(e.R.curves),e.S&&t(e.S.curves),e.T&&t(e.T.curves)}(_)}}x>T&&(this.stacks[a]={name:o[a].attrName,layers:b,length:x-T,frames:30*(x-T)})}return this},p.prototype.add=function(e){void 0===this.textures&&(this.textures=[]),this.textures.push(e);for(var t=0;t<e.parentIds.length;++t)void 0===this.perGeoMap[e.parentIds[t]]&&(this.perGeoMap[e.parentIds[t]]=[]),this.perGeoMap[e.parentIds[t]].push(this.textures[this.textures.length-1])},p.prototype.parse=function(e){var t=e.Objects.subNodes.Texture;for(var r in t){var i=(new m).parse(t[r],e);this.textures[r]=i}return this},p.prototype.getById=function(e){return this.perGeoMap[e]},m.prototype.parse=function(e,t){return this.id=e.id,this.name=e.attrName,this.fileName=this.parseFileName(e.properties.FileName),this.parentIds=this.searchParents(this.id,t),this},m.prototype.parseFileName=function(e){if(void 0===e)return"";var t=e.split(/[\\\/]/);return t.length>0?t[t.length-1]:e},m.prototype.searchParents=function(e,t){return t.searchConnectionParent(e)},Object.assign(f.prototype,{parse:function(e){var t=e.Objects.subNodes.Material;for(var r in t){var i=(new v).parse(t[r],e);this.materials[r]=i}return this}}),Object.assign(v.prototype,{parse:function(e,t){return this.id=e.id,this.name=e.attrName,this.type=e.properties.ShadingModel,this.parameters=this.parseParameters(e.properties),this.parentIds=this.searchParents(this.id,t),this},parseParameters:function(e){var t={};return e.Diffuse&&(t.color=(new THREE.Color).fromArray([parseFloat(e.Diffuse.value.x),parseFloat(e.Diffuse.value.y),parseFloat(e.Diffuse.value.z)])),e.Specular&&(t.specular=(new THREE.Color).fromArray([parseFloat(e.Specular.value.x),parseFloat(e.Specular.value.y),parseFloat(e.Specular.value.z)])),e.Shininess&&(t.shininess=e.Shininess.value),e.Emissive&&(t.emissive=(new THREE.Color).fromArray([parseFloat(e.Emissive.value.x),parseFloat(e.Emissive.value.y),parseFloat(e.Emissive.value.z)])),e.EmissiveFactor&&(t.emissiveIntensity=e.EmissiveFactor.value),e.Reflectivity&&(t.reflectivity=e.Reflectivity.value),e.Opacity&&(t.opacity=e.Opacity.value),t.opacity<1&&(t.transparent=!0),t},searchParents:function(e,t){return t.searchConnectionParent(e)}})}()},{}],3:[function(e,t,r){t.exports=THREE.PLYLoader=function(e){this.manager=void 0!==e?e:THREE.DefaultLoadingManager,this.propertyNameMapping={}},THREE.PLYLoader.prototype={constructor:THREE.PLYLoader,load:function(e,t,r,i){var n=this,o=new THREE.XHRLoader(this.manager);o.setResponseType("arraybuffer"),o.load(e,function(e){t(n.parse(e))},r,i)},setPropertyNameMapping:function(e){this.propertyNameMapping=e},bin2str:function(e){for(var t=new Uint8Array(e),r="",i=0;i<e.byteLength;i++)r+=String.fromCharCode(t[i]);return r},isASCII:function(e){return"ascii"===this.parseHeader(this.bin2str(e)).format},parse:function(e){return e instanceof ArrayBuffer?this.isASCII(e)?this.parseASCII(this.bin2str(e)):this.parseBinary(e):this.parseASCII(e)},parseHeader:function(e){var t=/ply([\s\S]*)end_header\s/,r="",i=0,n=t.exec(e);null!==n&&(r=n[1],i=n[0].length);for(var o,s,a={comments:[],elements:[],headerLength:i},c=r.split("\n"),h=void 0,l=0;l<c.length;l++){var u=c[l];if(""!==(u=u.trim()))switch(s=u.split(/\s+/),o=s.shift(),u=s.join(" "),o){case"format":a.format=s[0],a.version=s[1];break;case"comment":a.comments.push(u);break;case"element":void 0!==h&&a.elements.push(h),h=Object(),h.name=s[0],h.count=parseInt(s[1]), | ||
h.properties=[];break;case"property":h.properties.push(function(e,t){var r={type:e[0]};return"list"===r.type?(r.name=e[3],r.countType=e[1],r.itemType=e[2]):r.name=e[1],r.name in t&&(r.name=t[r.name]),r}(s,this.propertyNameMapping));break;default:console.log("unhandled",o,s)}}return void 0!==h&&a.elements.push(h),a},parseASCIINumber:function(e,t){switch(t){case"char":case"uchar":case"short":case"ushort":case"int":case"uint":case"int8":case"uint8":case"int16":case"uint16":case"int32":case"uint32":return parseInt(e);case"float":case"double":case"float32":case"float64":return parseFloat(e)}},parseASCIIElement:function(e,t){for(var r=t.split(/\s+/),i=Object(),n=0;n<e.length;n++)if("list"===e[n].type){for(var o=[],s=this.parseASCIINumber(r.shift(),e[n].countType),a=0;a<s;a++)o.push(this.parseASCIINumber(r.shift(),e[n].itemType));i[e[n].name]=o}else i[e[n].name]=this.parseASCIINumber(r.shift(),e[n].type);return i},parseASCII:function(e){var t,r=new THREE.Geometry,i=this.parseHeader(e),n=/end_header\s([\s\S]*)$/,o="";null!==(t=n.exec(e))&&(o=t[1]);var s=o.split("\n"),a=0,c=0;r.useColor=!1;for(var h=0;h<s.length;h++){var l=s[h];if(""!==(l=l.trim())){c>=i.elements[a].count&&(a++,c=0);var u=this.parseASCIIElement(i.elements[a].properties,l);this.handleElement(r,i.elements[a].name,u),c++}}return this.postProcess(r)},postProcess:function(e){if(e.useColor){for(var t=0;t<e.faces.length;t++)e.faces[t].vertexColors=[e.colors[e.faces[t].a],e.colors[e.faces[t].b],e.colors[e.faces[t].c]];e.elementsNeedUpdate=!0}return e.computeBoundingSphere(),e},handleElement:function(e,t,r){if("vertex"===t){if(e.vertices.push(new THREE.Vector3(r.x,r.y,r.z)),"red"in r&&"green"in r&&"blue"in r){e.useColor=!0;var i=new THREE.Color;i.setRGB(r.red/255,r.green/255,r.blue/255),e.colors.push(i)}}else if("face"===t){var n=r.vertex_indices||r.vertex_index;3===n.length?e.faces.push(new THREE.Face3(n[0],n[1],n[2])):4===n.length&&e.faces.push(new THREE.Face3(n[0],n[1],n[3]),new THREE.Face3(n[1],n[2],n[3]))}},binaryRead:function(e,t,r,i){switch(r){case"int8":case"char":return[e.getInt8(t),1];case"uint8":case"uchar":return[e.getUint8(t),1];case"int16":case"short":return[e.getInt16(t,i),2];case"uint16":case"ushort":return[e.getUint16(t,i),2];case"int32":case"int":return[e.getInt32(t,i),4];case"uint32":case"uint":return[e.getUint32(t,i),4];case"float32":case"float":return[e.getFloat32(t,i),4];case"float64":case"double":return[e.getFloat64(t,i),8]}},binaryReadElement:function(e,t,r,i){for(var n,o=Object(),s=0,a=0;a<r.length;a++)if("list"===r[a].type){var c=[];n=this.binaryRead(e,t+s,r[a].countType,i);var h=n[0];s+=n[1];for(var l=0;l<h;l++)n=this.binaryRead(e,t+s,r[a].itemType,i),c.push(n[0]),s+=n[1];o[r[a].name]=c}else n=this.binaryRead(e,t+s,r[a].type,i),o[r[a].name]=n[0],s+=n[1];return[o,s]},parseBinary:function(e){for(var t,r=new THREE.Geometry,i=this.parseHeader(this.bin2str(e)),n="binary_little_endian"===i.format,o=new DataView(e,i.headerLength),s=0,a=0;a<i.elements.length;a++)for(var c=0;c<i.elements[a].count;c++){t=this.binaryReadElement(o,s,i.elements[a].properties,n),s+=t[1];var h=t[0];this.handleElement(r,i.elements[a].name,h)}return this.postProcess(r)}}},{}],4:[function(e,t,r){function i(){return"script_"+Date.now()+"_"+Math.ceil(1e5*Math.random())}function n(e,t){var r=document.createElement("script");return r.type="text/javascript",r.async=!0,r.id=t,r.src=e,r}function o(e){const t=document.getElementById(e),r=t.parentNode;try{r&&r.removeChild(t)}catch(e){}}function s(e){const t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)}function a(e,t,r){return new r(function(r,a){const c=t.timeout||5e3,h=i(),l=n(e,h),u=setTimeout(function(){a(new Error("Script request to "+e+" timed out")),o(h)},c),d=function(e){clearTimeout(e)};l.addEventListener("load",function(e){r({ok:!0}),d(u),o(h)}),l.addEventListener("error",function(t){a(new Error("Script request to "+e+" failed "+t)),d(u),o(h)}),s(l)})}function c(e){return e=e||{},function(t,r){return r=r||{},a(t,r,e.Promise||Promise)}}t.exports=c},{}],5:[function(e,t,r){function i(e){return new RegExp("^"+e.split(/\*+/).map(n).join(".*")+"$")}function n(e){return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&")}var o={once:THREE.LoopOnce,repeat:THREE.LoopRepeat,pingpong:THREE.LoopPingPong};t.exports={schema:{clip:{default:"*"},duration:{default:0},crossFadeDuration:{default:0},loop:{default:"repeat",oneOf:Object.keys(o)},repetitions:{default:1/0,min:0}},init:function(){this.model=null,this.mixer=null,this.activeActions=[];var e=this.el.getObject3D("mesh");e?this.load(e):this.el.addEventListener("model-loaded",function(e){this.load(e.detail.model)}.bind(this))},load:function(e){var t=this.el;this.model=e,this.mixer=new THREE.AnimationMixer(e),this.mixer.addEventListener("loop",function(e){t.emit("animation-loop",{action:e.action,loopDelta:e.loopDelta})}.bind(this)),this.mixer.addEventListener("finished",function(e){t.emit("animation-finished",{action:e.action,direction:e.direction})}.bind(this)),this.data.clip&&this.update({})},remove:function(){this.mixer&&this.mixer.stopAllAction()},update:function(e){e&&(this.stopAction(),this.data.clip&&this.playAction())},stopAction:function(){for(var e=this.data,t=0;t<this.activeActions.length;t++)e.crossFadeDuration?this.activeActions[t].fadeOut(e.crossFadeDuration):this.activeActions[t].stop();this.activeActions.length=0},playAction:function(){if(this.mixer){var e=this.model,t=this.data,r=e.animations||(e.geometry||{}).animations||[];if(r.length)for(var n,s=i(t.clip),a=0;n=r[a];a++)if(n.name.match(s)){var c=this.mixer.clipAction(n,e);c.enabled=!0,t.duration&&c.setDuration(t.duration),c.setLoop(o[t.loop],t.repetitions).fadeIn(t.crossFadeDuration).play(),this.activeActions.push(c)}}},tick:function(e,t){this.mixer&&!isNaN(t)&&this.mixer.update(t/1e3)}}},{}],6:[function(e,t,r){THREE.FBXLoader=e("../../lib/FBXLoader"),t.exports={schema:{src:{type:"asset"},crossorigin:{default:""}},init:function(){this.model=null},update:function(){var e,t=this.data;t.src&&(this.remove(),e=new THREE.FBXLoader,t.crossorigin&&e.setCrossOrigin(t.crossorigin),e.load(t.src,this.load.bind(this)))},load:function(e){this.model=e,this.el.setObject3D("mesh",e),this.el.emit("model-loaded",{format:"fbx",model:e})},remove:function(){this.model&&this.el.removeObject3D("mesh")}}},{"../../lib/FBXLoader":2}],7:[function(e,t,r){var i=e("../../lib/fetch-script")();void 0===THREE.PropertyBinding.sanitizeNodeName&&(THREE.PropertyBinding.sanitizeNodeName=function(e){return e.replace(/\./g,"_")}),t.exports={schema:{type:"model"},init:function(){this.model=null,this.loader=null,this.loaderPromise=n().then(function(){this.loader=new THREE.GLTF2Loader}.bind(this))},update:function(){var e=this,t=this.el,r=this.data;r&&(this.remove(),this.loaderPromise.then(function(){this.loader.load(r,function(r){e.model=r.scene,e.model.animations=r.animations,t.setObject3D("mesh",e.model),t.emit("model-loaded",{format:"gltf",model:e.model})})}.bind(this)))},remove:function(){this.model&&this.el.removeObject3D("mesh")}};var n=function(){var e;return function(){return e=e||i("https://rawgit.com/mrdoob/three.js/dev/examples/js/loaders/GLTF2Loader.js")}}()},{"../../lib/fetch-script":4}],8:[function(e,t,r){t.exports={"animation-mixer":e("./animation-mixer"),"fbx-model":e("./fbx-model"),"gltf-model-next":e("./gltf-model-next"),"json-model":e("./json-model"),"object-model":e("./object-model"),"ply-model":e("./ply-model"),"three-model":e("./three-model"),registerAll:function(e){this._registered||(e=e||window.AFRAME,e.components["animation-mixer"]||e.registerComponent("animation-mixer",this["animation-mixer"]),e.systems["ply-model"]||e.registerSystem("ply-model",this["ply-model"].System),e.components["ply-model"]||e.registerComponent("ply-model",this["ply-model"].Component),e.components["fbx-model"]||e.registerComponent("fbx-model",this["fbx-model"]),e.components["gltf-model-next"]||e.registerComponent("gltf-model-next",this["gltf-model-next"]),e.components["json-model"]||e.registerComponent("json-model",this["json-model"]),e.components["object-model"]||e.registerComponent("object-model",this["object-model"]),e.components["three-model"]||e.registerComponent("three-model",this["three-model"]),this._registered=!0)}}},{"./animation-mixer":5,"./fbx-model":6,"./gltf-model-next":7,"./json-model":9,"./object-model":10,"./ply-model":11,"./three-model":12}],9:[function(e,t,r){t.exports={schema:{src:{type:"asset"},crossorigin:{default:""}},init:function(){this.model=null},update:function(){var e,t=this.data;t.src&&(this.remove(),e=new THREE.JSONLoader,t.crossorigin&&(e.crossOrigin=t.crossorigin),e.load(t.src,function(e,t){t.forEach(function(t){t.vertexColors=(e.faces[0]||{}).color?THREE.FaceColors:THREE.NoColors,t.skinning=!!(e.bones||[]).length,t.morphTargets=!!(e.morphTargets||[]).length,t.morphNormals=!!(e.morphNormals||[]).length});var r=(e.bones||[]).length?new THREE.SkinnedMesh(e,new THREE.MultiMaterial(t)):new THREE.Mesh(e,new THREE.MultiMaterial(t));this.load(r)}.bind(this)))},load:function(e){this.model=e,this.el.setObject3D("mesh",e),this.el.emit("model-loaded",{format:"json",model:e})},remove:function(){this.model&&this.el.removeObject3D("mesh")}}},{}],10:[function(e,t,r){t.exports={schema:{src:{type:"asset"},crossorigin:{default:""}},init:function(){this.model=null},update:function(){var e,t=this.data;t.src&&(this.remove(),e=new THREE.ObjectLoader,t.crossorigin&&e.setCrossOrigin(t.crossorigin),e.load(t.src,function(e){e.traverse(function(e){e instanceof THREE.SkinnedMesh&&e.material&&(e.material.skinning=!!(e.geometry&&e.geometry.bones||[]).length)}),this.load(e)}.bind(this)))},load:function(e){this.model=e,this.el.setObject3D("mesh",e),this.el.emit("model-loaded",{format:"json",model:e})},remove:function(){this.model&&this.el.removeObject3D("mesh")}}},{}],11:[function(e,t,r){function i(e){return new THREE.Mesh(e,new THREE.MeshPhongMaterial({color:16777215,shading:THREE.FlatShading,vertexColors:THREE.VertexColors,shininess:0}))}THREE.PLYLoader=e("../../lib/PLYLoader"),t.exports.System={init:function(){this.cache={}},getOrLoadGeometry:function(e,t){var r=this.cache,i=r[e];return!t&&i?i:(r[e]=new Promise(function(t){(new THREE.PLYLoader).load(e,function(e){t(e)})}),r[e])}},t.exports.Component={schema:{skipCache:{type:"boolean",default:!1},src:{type:"asset"}},init:function(){this.model=null},update:function(){var e=this.data,t=this.el;if(!e.src)return void console.warn("[%s] `src` property is required.",this.name);this.system.getOrLoadGeometry(e.src,e.skipCache).then(function(e){var r=i(e);t.setObject3D("mesh",r),t.emit("model-loaded",{format:"ply",model:r})})},remove:function(){this.model&&this.el.removeObject3D("mesh")}}},{"../../lib/PLYLoader":3}],12:[function(e,t,r){t.exports={deprecated:!0,schema:{src:{type:"asset"},loader:{default:"object",oneOf:["object","json"]},enableAnimation:{default:!0},animation:{default:"__auto__"},animationDuration:{default:0},crossorigin:{default:""}},init:function(){this.model=null,this.mixer=null,console.warn("[three-model] Component is deprecated. Use json-model or object-model instead.")},update:function(e){e=e||{};var t,r=this.data;if(!r.src)return void this.remove();if(Object.keys(e).length){var i=this.model&&this.model.activeAction;if(r.animation!==e.animation)return i&&i.stop(),void this.playAnimation();i&&r.enableAnimation!==i.isRunning()&&(r.enableAnimation?this.playAnimation():i.stop()),i&&r.animationDuration&&i.setDuration(r.animationDuration)}else if(this.remove(),"object"===r.loader)t=new THREE.ObjectLoader,r.crossorigin&&t.setCrossOrigin(r.crossorigin),t.load(r.src,function(e){e.traverse(function(t){t instanceof THREE.SkinnedMesh&&(e=t)}),e.material&&(e.material.skinning=!!(e.geometry&&e.geometry.bones||[]).length),this.load(e)}.bind(this));else{if("json"!==r.loader)throw new Error('[three-model] Invalid mode "%s".',r.mode);t=new THREE.JSONLoader,r.crossorigin&&(t.crossOrigin=r.crossorigin),t.load(r.src,function(e,t){t.forEach(function(t){t.vertexColors=(e.faces[0]||{}).color?THREE.FaceColors:THREE.NoColors,t.skinning=!!(e.bones||[]).length,t.morphTargets=!!(e.morphTargets||[]).length,t.morphNormals=!!(e.morphNormals||[]).length});var r=(e.bones||[]).length?new THREE.SkinnedMesh(e,new THREE.MultiMaterial(t)):new THREE.Mesh(e,new THREE.MultiMaterial(t));this.load(r)}.bind(this))}},load:function(e){this.model=e,this.mixer=new THREE.AnimationMixer(this.model),this.el.setObject3D("mesh",e),this.el.emit("model-loaded",{format:"three",model:e}),this.data.enableAnimation&&this.playAnimation()},playAnimation:function(){var e,t=this.data,r=this.model.animations||this.model.geometry.animations||[];if(t.enableAnimation&&t.animation&&r.length){if(!(e="__auto__"===t.animation?r[0]:THREE.AnimationClip.findByName(r,t.animation)))return void console.error('[three-model] Animation "%s" not found.',t.animation);this.model.activeAction=this.mixer.clipAction(e,this.model),t.animationDuration&&this.model.activeAction.setDuration(t.animationDuration),this.model.activeAction.play()}},remove:function(){this.mixer&&this.mixer.stopAllAction(),this.model&&this.el.removeObject3D("mesh")},tick:function(e,t){this.mixer&&!isNaN(t)&&this.mixer.update(t/1e3)}}},{}]},{},[1]); | ||
!function e(t,r,i){function n(s,a){if(!r[s]){if(!t[s]){var c="function"==typeof require&&require;if(!a&&c)return c(s,!0);if(o)return o(s,!0);var h=new Error("Cannot find module '"+s+"'");throw h.code="MODULE_NOT_FOUND",h}var l=r[s]={exports:{}};t[s][0].call(l.exports,function(e){var r=t[s][1][e];return n(r||e)},l,l.exports,e,t,r,i)}return r[s].exports}for(var o="function"==typeof require&&require,s=0;s<i.length;s++)n(i[s]);return n}({1:[function(e,t,r){e("./src/loaders").registerAll()},{"./src/loaders":9}],2:[function(e,t,r){!function(){function e(){}function r(){}function i(){this.skinIndices=[],this.skinWeights=[],this.matrices=[]}function n(){this.hierarchy=[]}function o(){this.geometries={}}function s(){this.node=null,this.name=null,this.id=null,this.vertices=[],this.indices=[],this.normals=[],this.uvs=[],this.bones=[]}function a(){this.uv=null,this.map=null,this.ref=null,this.node=null,this.index=null}function c(){this.normal=null,this.map=null,this.ref=null,this.node=null,this.index=null}function h(){this.indexBuffer=[]}function l(){this.version=null,this.id=null,this.internalId=null,this.times=null,this.values=null,this.attrFlag=null,this.attrData=null}function d(){this.id=null,this.attr=null,this.attrX=!1,this.attrY=!1,this.attrZ=!1,this.internalId=null,this.containerInternalId=null,this.containerBoneId=null,this.curveIdx=null,this.curves={}}function u(){this.curves={},this.length=0,this.fps=30,this.frames=0}function p(){this.textures={}}function m(){this.fileName="",this.name="",this.id=null,this.parentIds=[]}function f(){this.materials={},this.perGeoMap={}}function y(){this.fileName="",this.name="",this.id=null,this.parentIds=[]}function v(e,t,r){for(var i=[],n=0;n<t.length;++n)for(var o=0;o<r;++o)i.push(e[t[n]*r+o]);return i}function g(e,t,r,i){for(var n=[],o=0,s=0;s<t.length;++s){n[t[s]]=[];for(var a=0;a<i;++a)n[t[s]][a]=e[o+a];o+=i}for(var c=[],h=0;h<n.length;++h)if(void 0!==n[h])for(var l=0;l<i;++l)void 0!==n[h][l]&&c.push(n[h][l]);return c}function _(e,t,r){for(var i={},n=[],o=0,s=0;s<t.length;++s)if(!(t[s]in i)){i[t[s]]={};for(var a=0;a<r;++a)i[t[s]][a]=e[s*r+a];o=o<t[s]?t[s]:o}try{for(s=0;s<=o;s++)for(var c=0;c<r;c++)n.push(i[s][c])}catch(e){}return n}function E(e){return e/46186158e3}function b(e){return e*Math.PI/180}function x(e,t,r){var i=new THREE.Euler(e,t,r,"ZYX"),n=new THREE.Quaternion;return n.setFromEuler(i),n}function T(e){return e.split(",").map(function(e){return parseInt(e)})}function w(e){return e.split(",").map(function(e){return parseFloat(e)})}function N(e){return e.split(",").map(function(e){return b(parseFloat(e))})}function I(e){var t=w(e);return(new THREE.Matrix4).fromArray(t)}t.exports=THREE.FBXLoader=function(e){THREE.Loader.call(this),this.manager=void 0!==e?e:THREE.DefaultLoadingManager,this.textureLoader=null,this.textureBasePath=null},THREE.FBXLoader.prototype=Object.create(THREE.Loader.prototype),THREE.FBXLoader.prototype.constructor=THREE.FBXLoader,Object.assign(THREE.FBXLoader.prototype,{load:function(e,t,r,i){var n=this;new THREE.XHRLoader(n.manager).load(e,function(r){n.isFbxFormatASCII(r)?n.isFbxVersionSupported(r)?(n.textureBasePath=n.extractUrlBase(e),t(n.parse(r))):console.warn("FBXLoader: !!! FBX Version below 7 not supported !!!"):console.warn("FBXLoader: !!! FBX Binary format not supported !!!")},r,i)},setCrossOrigin:function(e){this.crossOrigin=e},isFbxFormatASCII:function(e){for(var t=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"],r=0,i=0;i<t.length;++i){if(function(t){var i=e[t-1];return e=e.slice(r+t),r++,i}(1)==t[i])return!1}return!0},isFbxVersionSupported:function(e){var t=/FBXVersion: (\d+)/,r=e.match(t);if(r){var i=parseInt(r[1]);return console.log("FBXLoader: FBX version "+i),i>=7e3}return!1},parse:function(e){var t=this;console.time("FBXLoader"),console.time("FBXLoader: TextParser");var s=(new r).parse(e);console.timeEnd("FBXLoader: TextParser"),console.time("FBXLoader: ObjectParser"),t.hierarchy=(new n).parseHierarchy(s),t.weights=(new i).parse(s,t.hierarchy),t.animations=(new u).parse(s,t.hierarchy),t.textures=(new p).parse(s,t.hierarchy),t.materials=(new f).parse(s,t.hierarchy),t.geometries=(new o).parse(s,t.hierarchy),console.timeEnd("FBXLoader: ObjectParser"),this.texture_cache={},this.material_cache={},this.geometry_cache={},console.time("FBXLoader: MeshParser");var a=this.parseMeshes(s);console.timeEnd("FBXLoader: MeshParser");for(var c=new THREE.Group,h=0;h<a.length;++h)void 0!==a[h]&&c.add(a[h]);return console.timeEnd("FBXLoader"),c},getTexture:function(e){return e.id in this.texture_cache||(null===this.textureLoader&&(this.textureLoader=new THREE.TextureLoader),this.texture_cache[e.id]=this.textureLoader.load(this.textureBasePath+"/"+e.fileName)),this.texture_cache[e.id]},getMaterial:function(e,t){if(!(e.id in this.material_cache)){var r;switch(e.type){case"phong":r=new THREE.MeshPhongMaterial;break;case"lambert":r=new THREE.MeshLambertMaterial;break;default:console.warn("No implementation given for material type "+e.type+" in FBXLoader.js. Defaulting to basic material"),r=new THREE.MeshBasicMaterial({color:3342591})}for(var i=t.searchConnectionChildren(e.id),n=0;n<i.length;++n){var o=t.searchConnectionType(i[n],e.id);switch(o){case' "AmbientColor':break;case' "DiffuseColor':e.parameters.map=this.getTexture(this.textures.textures[i[n]]);break;default:console.warn("Unknown texture application of type "+o+", skipping texture")}}r.setValues(e.parameters),this.material_cache[e.id]=r}return this.material_cache[e.id]},getGeometry:function(e){if(!(e.id in this.geometry_cache)){var t=new THREE.BufferGeometry;if(t.name=e.name,t.addAttribute("position",new THREE.BufferAttribute(new Float32Array(e.vertices),3)),void 0!==e.normals&&e.normals.length>0&&t.addAttribute("normal",new THREE.BufferAttribute(new Float32Array(e.normals),3)),void 0!==e.uvs&&e.uvs.length>0&&t.addAttribute("uv",new THREE.BufferAttribute(new Float32Array(e.uvs),2)),void 0!==e.indices&&e.indices.length>0&&(e.indices.length>65535?t.setIndex(new THREE.BufferAttribute(new Uint32Array(e.indices),1)):t.setIndex(new THREE.BufferAttribute(new Uint16Array(e.indices),1))),t.verticesNeedUpdate=!0,t.computeBoundingSphere(),t.computeBoundingBox(),e.materialIndices.length>1){t.groups=[];for(var r=0,i=-1;r<e.materialIndices.length;++r)e.materialIndices[r]!==i&&(t.groups.push({start:3*r,count:0,materialIndex:e.materialIndices[r]}),i=e.materialIndices[r]),t.groups[t.groups.length-1].count+=3}this.geometry_cache[e.id]=(new THREE.Geometry).fromBufferGeometry(t),this.geometry_cache[e.id].bones=e.bones,this.geometry_cache[e.id].skinIndices=this.weights.skinIndices,this.geometry_cache[e.id].skinWeights=this.weights.skinWeights}return this.geometry_cache[e.id]},parseMeshes:function(e){var t=e.Objects.subNodes.Model,r=[];for(var i in t)"Mesh"===t[i].attrType&&r.push(this.parseMesh(t[i],e));return r},parseMesh:function(e,t){for(var r,i,n,o=t.Objects.subNodes.Geometry,s=t.Objects.subNodes.Material,a=t.searchConnectionChildren(e.id),c=[],h=0;h<a.length;++h)a[h]in o?r=this.getGeometry(this.geometries.geometries[a[h]]):a[h]in s&&c.push(this.getMaterial(this.materials.materials[a[h]],t));if(i=c.length>1?new THREE.MultiMaterial(c):c[0],void 0!==r.bones&&void 0!==r.skinWeights){if(i instanceof THREE.MultiMaterial)for(var h=0;h<i.materials.length;++h)i.materials[h].skinning=!0;else i.skinning=!0;n=new THREE.SkinnedMesh(r,i)}else n=new THREE.Mesh(r,i);return void 0!==this.animations&&this.addAnimation(n,this.weights.matrices,this.animations),n},addAnimation:function(e,t,r){function i(e,t){if(void 0===e)return!1;var r;switch(t){case"S":if(!e.S)return!1;r=e.S;break;case"R":if(!e.R)return!1;r=e.R;break;case"T":if(!e.T)return!1;r=e.T}return void 0!==r.curves.x&&(void 0!==r.curves.y&&void 0!==r.curves.z)}function n(e,t){var r=o(e.curves.x,t),i=o(e.curves.y,t),n=o(e.curves.z,t);return r&&i&&n}function o(e,t){return void 0!==e.values[t]}for(var s in r.stacks){for(var a={name:r.stacks[s].name,fps:30,length:r.stacks[s].length,hierarchy:[]},c=0;c<e.geometry.bones.length;++c){var h=e.geometry.bones[c].name;h=h.replace(/.*:/,""),a.hierarchy.push({parent:e.geometry.bones[c].parent,name:h,keys:[]})}for(var l=e.geometry.bones,d=0;d<r.stacks[s].frames;d++)for(c=0;c<l.length;c++)for(var u=l[c],p=r.stacks[s].layers[0][c],m=0;m<a.hierarchy.length;m++)a.hierarchy[m].name===u.name&&a.hierarchy[m].keys.push(function(e,t){var o={};if(o.time=d/r.fps,o.pos=t.pos,o.rot=t.rotq,o.scl=t.scl,void 0===e)return o;try{if(i(e,"T")&&n(e.T,d)){var s=new THREE.Vector3(e.T.curves.x.values[d],e.T.curves.y.values[d],e.T.curves.z.values[d]);o.pos=[s.x,s.y,s.z]}if(i(e,"R")&&n(e.R,d)){var a=b(e.R.curves.x.values[d]),c=b(e.R.curves.y.values[d]),h=b(e.R.curves.z.values[d]),l=new THREE.Vector3(a,c,h),u=x(l.x,l.y,l.z);o.rot=[u.x,u.y,u.z,u.w]}if(i(e,"S")&&n(e.S,d)){var p=new THREE.Vector3(e.S.curves.x.values[d],e.S.curves.y.values[d],e.S.curves.z.values[d]);o.scl=[p.x,p.y,p.z]}}catch(e){console.log(t),console.log(e)}return o}(p,u));void 0===e.geometry.animations&&(e.geometry.animations=[]),e.geometry.animations.push(THREE.AnimationClip.parseAnimation(a,e.geometry.bones))}},loadFile:function(e,t,r,i,n){var o=new THREE.XHRLoader(this.manager);return o.setResponseType(n),o.load(e,t,r,i)},loadFileAsBuffer:function(e,t,r,i){this.loadFile(e,t,r,i,"arraybuffer")},loadFileAsText:function(e,t,r,i){this.loadFile(e,t,r,i,"text")}}),Object.assign(e.prototype,{add:function(e,t){this[e]=t},searchConnectionParent:function(e){if(void 0===this.__cache_search_connection_parent&&(this.__cache_search_connection_parent=[]),void 0!==this.__cache_search_connection_parent[e])return this.__cache_search_connection_parent[e];this.__cache_search_connection_parent[e]=[];for(var t=this.Connections.properties.connections,r=[],i=0;i<t.length;++i)if(t[i][0]==e){var n=0===t[i][1]?-1:t[i][1];r.push(n)}return r.length>0?(this.__cache_search_connection_parent[e]=this.__cache_search_connection_parent[e].concat(r),r):(this.__cache_search_connection_parent[e]=[-1],[-1])},searchConnectionChildren:function(e){if(void 0===this.__cache_search_connection_children&&(this.__cache_search_connection_children=[]),void 0!==this.__cache_search_connection_children[e])return this.__cache_search_connection_children[e];this.__cache_search_connection_children[e]=[];for(var t=this.Connections.properties.connections,r=[],i=0;i<t.length;++i)t[i][1]==e&&r.push(0===t[i][0]?-1:t[i][0]);return r.length>0?(this.__cache_search_connection_children[e]=this.__cache_search_connection_children[e].concat(r),r):(this.__cache_search_connection_children[e]=[],[])},searchConnectionType:function(e,t){var r=e+","+t;if(void 0===this.__cache_search_connection_type&&(this.__cache_search_connection_type={}),void 0!==this.__cache_search_connection_type[r])return this.__cache_search_connection_type[r];this.__cache_search_connection_type[r]="";for(var i=this.Connections.properties.connections,n=0;n<i.length;++n)if(i[n][0]==e&&i[n][1]==t)return this.__cache_search_connection_type[r]=i[n][2],i[n][2];return this.__cache_search_connection_type[e]=null,null}}),Object.assign(r.prototype,{getPrevNode:function(){return this.nodeStack[this.currentIndent-2]},getCurrentNode:function(){return this.nodeStack[this.currentIndent-1]},getCurrentProp:function(){return this.currentProp},pushStack:function(e){this.nodeStack.push(e),this.currentIndent+=1},popStack:function(){this.nodeStack.pop(),this.currentIndent-=1},setCurrentProp:function(e,t){this.currentProp=e,this.currentPropName=t},parse:function(t){this.currentIndent=0,this.allNodes=new e,this.nodeStack=[],this.currentProp=[],this.currentPropName="";var r=t.split("\n");for(var i in r){var n=r[i];if(!n.match(/^[\s\t]*;/)&&!n.match(/^[\s\t]*$/)){var o=new RegExp("^\\t{"+this.currentIndent+"}(\\w+):(.*){",""),s=n.match(o);if(s){var a=s[1].trim().replace(/^"/,"").replace(/"$/,""),c=s[2].split(",").map(function(e){return e.trim().replace(/^"/,"").replace(/"$/,"")});this.parseNodeBegin(n,a,c||null)}else{var h=new RegExp("^\\t{"+this.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),s=n.match(h);if(s){var l=s[1].replace(/^"/,"").replace(/"$/,"").trim(),d=s[2].replace(/^"/,"").replace(/"$/,"").trim();this.parseNodeProperty(n,l,d)}else{var u=new RegExp("^\\t{"+(this.currentIndent-1)+"}}");n.match(u)?this.nodeEnd():n.match(/^[^\s\t}]/)&&this.parseNodePropertyContinued(n)}}}}return this.allNodes},parseNodeBegin:function(e,t,r){var i={name:t,properties:{},subNodes:{}},n=this.parseNodeAttr(r),o=this.getCurrentNode();if(0===this.currentIndent)this.allNodes.add(t,i);else if(t in o.subNodes){var s=o.subNodes[t];this.isFlattenNode(o.subNodes[t])&&(""===n.id?(o.subNodes[t]=[],o.subNodes[t].push(s)):(o.subNodes[t]={},o.subNodes[t][s.id]=s)),""===n.id?o.subNodes[t].push(i):o.subNodes[t][n.id]=i}else"number"==typeof n.id||n.id.match(/^\d+$/)?(o.subNodes[t]={},o.subNodes[t][n.id]=i):o.subNodes[t]=i;r&&(i.id=n.id,i.attrName=n.name,i.attrType=n.type),this.pushStack(i)},parseNodeAttr:function(e){var t=e[0];""!==e[0]&&(t=parseInt(e[0]),isNaN(t)&&(t=e[0]));var r,i;return e.length>1&&(r=e[1].replace(/^(\w+)::/,""),i=e[2]),{id:t,name:r||"",type:i||""}},parseNodeProperty:function(e,t,r){var i=this.getCurrentNode(),n=i.name;if(void 0!==n){if(n.match(/Properties(\d)+/))return void this.parseNodeSpecialProperty(e,t,r)}if("C"==t){var o=r.split(",").slice(1),s=parseInt(o[0]),a=parseInt(o[1]),c=r.split(",").slice(3);t="connections",r=[s,a],r=r.concat(c),void 0===i.properties[t]&&(i.properties[t]=[])}if("Node"==t){var h=parseInt(r);i.properties.id=h,i.id=h}t in i.properties?Array.isArray(i.properties[t])?i.properties[t].push(r):i.properties[t]+=r:Array.isArray(i.properties[t])?i.properties[t].push(r):i.properties[t]=r,this.setCurrentProp(i.properties,t)},parseNodePropertyContinued:function(e){this.currentProp[this.currentPropName]+=e},parseNodeSpecialProperty:function(e,t,r){var i=r.split('",').map(function(e){return e.trim().replace(/^\"/,"").replace(/\s/,"_")}),n=i[0],o=i[1],s=i[2],a=i[3],c=i[4];switch(o){case"int":c=parseInt(c);break;case"double":c=parseFloat(c);break;case"ColorRGB":case"Vector3D":var h=c.split(",");c=new THREE.Vector3(h[0],h[1],h[2])}this.getPrevNode().properties[n]={type:o,type2:s,flag:a,value:c},this.setCurrentProp(this.getPrevNode().properties,n)},nodeEnd:function(){this.popStack()},isFlattenNode:function(e){return"subNodes"in e&&"properties"in e}}),i.prototype.parseCluster=function(e,t,r){var i=e.searchConnectionParent(t),n=T(r.subNodes.Indexes.properties.a),o=w(r.subNodes.Weights.properties.a),s=I(r.subNodes.Transform.properties.a),a=I(r.subNodes.TransformLink.properties.a);return{parent:i,id:parseInt(t),indices:n,weights:o,transform:s,transformlink:a,linkMode:r.properties.Mode}},i.prototype.parse=function(e,t){this.skinIndices=[],this.skinWeights=[],this.matrices=[];var r=e.Objects.subNodes.Deformer,i={};for(var n in r)if("Cluster"===r[n].attrType){if(!("Indexes"in r[n].subNodes))continue;var o=this.parseCluster(e,n,r[n]),s=e.searchConnectionChildren(o.id)[0];i[s]=o}for(var a=[],c=t.hierarchy,h=0;h<c.length;++h){var l=c[h].internalId;if(void 0!==i[l]){var d=i[l];this.matrices.push(d.transform);for(var u=0;u<d.indices.length;++u){void 0===a[d.indices[u]]&&(a[d.indices[u]]={},a[d.indices[u]].joint=[],a[d.indices[u]].weight=[]);var p=e.searchConnectionChildren(d.id);p.length>1&&console.warn("FBXLoader: node "+d.id+" have many weight kids: "+p),a[d.indices[u]].joint.push(t.getBoneIdfromInternalId(e,p[0])),a[d.indices[u]].weight.push(d.weights[u])}}else this.matrices.push(new THREE.Matrix4)}for(var m=0;m<a.length;m++)if(void 0!==a[m]){var f=new THREE.Vector4(a[m].joint[0]?a[m].joint[0]:0,a[m].joint[1]?a[m].joint[1]:0,a[m].joint[2]?a[m].joint[2]:0,a[m].joint[3]?a[m].joint[3]:0),y=new THREE.Vector4(a[m].weight[0]?a[m].weight[0]:0,a[m].weight[1]?a[m].weight[1]:0,a[m].weight[2]?a[m].weight[2]:0,a[m].weight[3]?a[m].weight[3]:0);this.skinIndices.push(f),this.skinWeights.push(y)}else this.skinIndices.push(new THREE.Vector4(0,0,0,0)),this.skinWeights.push(new THREE.Vector4(0,0,0,0));return this},n.prototype.parseHierarchy=function(e){var t=e.Objects,r=t.subNodes.Model,i=[];for(var n in r)void 0!==r[n].attrType&&i.push(r[n]);this.hierarchy=[];for(var o=0;o<i.length;++o){var s=i[o],a=e.searchConnectionParent(s.id)[0],c=[0,0,0],h=[0,0,0,1],l=[1,1,1];if("Lcl_Translation"in s.properties&&(c=w(s.properties.Lcl_Translation.value)),"Lcl_Rotation"in s.properties){h=N(s.properties.Lcl_Rotation.value);var d=new THREE.Quaternion;d.setFromEuler(new THREE.Euler(h[0],h[1],h[2],"ZYX")),h=[d.x,d.y,d.z,d.w]}"Lcl_Scaling"in s.properties&&(l=w(s.properties.Lcl_Scaling.value));var u=s.attrName;u=u.replace(/:/,""),u=u.replace(/_/,""),u=u.replace(/-/,""),this.hierarchy.push({parent:a,name:u,pos:c,rotq:h,scl:l,internalId:s.id})}return this.reindexParentId(),this.restoreBindPose(e),this},n.prototype.reindexParentId=function(){for(var e=0;e<this.hierarchy.length;e++)for(var t=0;t<this.hierarchy.length;++t)if(this.hierarchy[e].parent==this.hierarchy[t].internalId){this.hierarchy[e].parent=t;break}},n.prototype.restoreBindPose=function(e){var t=e.Objects.subNodes.Pose;if(void 0!==t){for(var r in t)if("BindPose"===t[r].attrType){t=t[r];break}for(var i=t.subNodes.PoseNode,n={},o={},s=0;s<i.length;++s){var a=I(i[s].subNodes.Matrix.properties.a),c=I(i[s].subNodes.Matrix.properties.a);n[i[s].id]=a,o[i[s].id]=c}for(var h=0;h<this.hierarchy.length;++h){var l=this.hierarchy[h],d=l.internalId;if(void 0!==o[d]){for(var u,p=new THREE.Vector3(0,0,0),m=new THREE.Quaternion,f=new THREE.Vector3(1,1,1),y=e.searchConnectionParent(d),v=0;v<y.length;++v)if(this.isBoneNode(y[v])){u=y[v];break}if(void 0!==u&&void 0!==n[u]){var g=new THREE.Matrix4;g.getInverse(o[u]),g.multiply(n[d]),n[d]=g}n[d].decompose(p,m,f),l.pos=[p.x,p.y,p.z],l.rotq=[m.x,m.y,m.z,m.w],l.scl=[f.x,f.y,f.z]}}}},n.prototype.searchRealId=function(e){for(var t=0;t<this.hierarchy.length;t++)if(e==this.hierarchy[t].internalId)return t;return-1},n.prototype.getByInternalId=function(e){for(var t=0;t<this.hierarchy.length;t++)if(e==this.hierarchy[t].internalId)return this.hierarchy[t];return null},n.prototype.isBoneNode=function(e){for(var t=0;t<this.hierarchy.length;++t)if(e===this.hierarchy[t].internalId)return!0;return!1},n.prototype.getBoneIdfromInternalId=function(e,t){if(void 0===e.__cache_get_boneid_from_internalid&&(e.__cache_get_boneid_from_internalid=[]),void 0!==e.__cache_get_boneid_from_internalid[t])return e.__cache_get_boneid_from_internalid[t];for(var r=0;r<this.hierarchy.length;++r)if(this.hierarchy[r].internalId==t)return e.__cache_get_boneid_from_internalid[t]=r,r;return-1},Object.assign(o.prototype,{parse:function(e,t){if(!("Geometry"in e.Objects.subNodes))return this;for(var r in e.Objects.subNodes.Geometry)"Mesh"===e.Objects.subNodes.Geometry[r].attrType&&(this.geometries[r]=(new s).parse(e.Objects.subNodes.Geometry[r]),this.geometries[r].addBones(t.hierarchy));return this}}),s.prototype.parse=function(e){if(this.node=e,this.name=e.attrName,this.id=e.id,this.vertices=this.getVertices(),void 0===this.vertices)return void console.log("FBXLoader: Geometry.parse(): pass"+this.node.id);if(this.indices=this.getPolygonVertexIndices(),this.uvs=(new a).parse(this.node,this),this.normals=(new c).parse(this.node,this),this.materialIndices=(new h).parse(this.node),this.getPolygonTopologyMax()>3){var t=this.convertPolyIndicesToTri(this.indices,this.materialIndices,this.getPolygonTopologyArray());this.indices=t.res,this.materialIndices=t.materialIndices,this.polyIndices=t.polyIndices}return this},s.prototype.getVertices=function(){if(this.node.__cache_vertices)return this.node.__cache_vertices;if(void 0===this.node.subNodes.Vertices)return console.warn("this.node: "+this.node.attrName+"("+this.node.id+") does not have Vertices"),this.node.__cache_vertices=void 0,null;var e=this.node.subNodes.Vertices.properties.a,t=e.split(",").map(function(e){return parseFloat(e)});return this.node.__cache_vertices=t,this.node.__cache_vertices},s.prototype.getPolygonVertexIndices=function(){if(this.node.__cache_indices&&this.node.__cache_poly_topology_max)return this.node.__cache_indices;if(void 0===this.node.subNodes)return console.error("this.node.subNodes undefined"),void console.log(this.node);if(void 0===this.node.subNodes.PolygonVertexIndex)return console.warn("this.node: "+this.node.attrName+"("+this.node.id+") does not have PolygonVertexIndex "),void(this.node.__cache_indices=void 0);for(var e=this.node.subNodes.PolygonVertexIndex.properties.a,t=e.split(","),r=1,i=null,n=[],o=0;o<t.length;++o){var s=parseInt(t[o]);s<0?(r>i&&(i=r),t[o]=-1^s,n.push(r),r=1):(t[o]=s,r++)}return null===i&&(console.warn("FBXLoader: topology N not found: "+this.node.attrName),console.warn(this.node),i=3),this.node.__cache_poly_topology_max=i,this.node.__cache_poly_topology_arr=n,this.node.__cache_indices=t,this.node.__cache_indices},s.prototype.getPolygonTopologyMax=function(){return this.node.__cache_indices&&this.node.__cache_poly_topology_max?this.node.__cache_poly_topology_max:(this.getPolygonVertexIndices(this.node),this.node.__cache_poly_topology_max)},s.prototype.getPolygonTopologyArray=function(){return this.node.__cache_indices&&this.node.__cache_poly_topology_max?this.node.__cache_poly_topology_arr:(this.getPolygonVertexIndices(this.node),this.node.__cache_poly_topology_arr)},s.prototype.convertPolyIndicesToTri=function(e,t,r){for(var i=[],n=0,o=0,s=0,a=[];n<e.length;){s=r[o];for(var c=0;c<=s-3;c++)i.push(e[n]),i.push(e[n+(s-2-c)]),i.push(e[n+(s-1-c)]),a.push(o);o++,n+=s}var h=[t[0]];if(t.length>1)for(var n=0;n<a.length;++n)h[n]=t[a[n]];return{res:i,materialIndices:h,polyIndices:a}},s.prototype.addBones=function(e){this.bones=e},a.prototype.getUV=function(e){return this.node&&this.uv&&this.map&&this.ref?this.uv:this._parseText(e)},a.prototype.getMap=function(e){return this.node&&this.uv&&this.map&&this.ref?this.map:(this._parseText(e),this.map)},a.prototype.getRef=function(e){return this.node&&this.uv&&this.map&&this.ref?this.ref:(this._parseText(e),this.ref)},a.prototype.getIndex=function(e){return this.node&&this.uv&&this.map&&this.ref?this.index:(this._parseText(e),this.index)},a.prototype.getNode=function(e){return null!==this.node?this.node:(this.node=e.subNodes.LayerElementUV,this.node)},a.prototype._parseText=function(e){var t=this.getNode(e)[0];if(void 0===t)return[];var r=0;for(var i in t)i.match(/^\d+$/)&&r++;r>0&&(console.warn("multi uv not supported"),t=t[i]);var n=t.subNodes.UVIndex.properties.a,o=t.subNodes.UV.properties.a,s=t.properties.MappingInformationType,a=t.properties.ReferenceInformationType;return this.uv=w(o),this.index=T(n),this.map=s,this.ref=a,this.uv},a.prototype.parse=function(e,t){if("LayerElementUV"in e.subNodes){this.uvNode=this.getNode(e),this.uv=this.getUV(e);var r=this.getMap(e),i=this.getRef(e),n=this.getIndex(e),o=t.getPolygonTopologyArray();switch(r){case"ByPolygonVertex":switch(i){case"Direct":this.uv=this.parseUV_ByPolygonVertex_Direct(this.uv,n,o,2);break;case"IndexToDirect":this.uv=this.parseUV_ByPolygonVertex_IndexToDirect(this.uv,n)}this.uv=_(this.uv,t.getPolygonVertexIndices(e),2);break;case"ByPolygon":switch(i){case"Direct":this.uv=this.parseUV_ByPolygon_Direct();break;case"IndexToDirect":this.uv=this.parseUV_ByPolygon_IndexToDirect()}}return this.uv}},a.prototype.parseUV_ByPolygonVertex_Direct=function(e,t,r,i){return g(e,t,r,i)},a.prototype.parseUV_ByPolygonVertex_IndexToDirect=function(e,t){return v(e,t,2)},a.prototype.parseUV_ByPolygon_Direct=function(e){return console.warn("not implemented"),e},a.prototype.parseUV_ByPolygon_IndexToDirect=function(e){return console.warn("not implemented"),e},a.prototype.parseUV_ByVertex_Direct=function(e){return console.warn("not implemented"),e},c.prototype.getNormal=function(e){return this.node&&this.normal&&this.map&&this.ref?this.normal:(this._parseText(e),this.normal)},c.prototype.getMap=function(e){return this.node&&this.normal&&this.map&&this.ref?this.map:(this._parseText(e),this.map)},c.prototype.getRef=function(e){return this.node&&this.normal&&this.map&&this.ref?this.ref:(this._parseText(e),this.ref)},c.prototype.getNode=function(e){return this.node?this.node:(this.node=e.subNodes.LayerElementNormal,this.node)},c.prototype._parseText=function(e){var t=this.getNode(e)[0];if(void 0===t)return void console.warn("node: "+e.attrName+"("+e.id+") does not have LayerElementNormal");var r=t.properties.MappingInformationType,i=t.properties.ReferenceInformationType,n=t.subNodes.Normals.properties.a;this.normal=w(n),this.map=r,this.ref=i},c.prototype.parse=function(e,t){var r=this.getNormal(e),i=this.getMap(e),n=this.getRef(e),o=t.getPolygonVertexIndices(e),s=t.getPolygonTopologyArray(e);switch(i){case"ByPolygonVertex":switch(n){case"Direct":r=this.parseNormal_ByPolygonVertex_Direct(r,o,s,3);break;case"IndexToDirect":r=this.parseNormal_ByPolygonVertex_IndexToDirect()}break;case"ByPolygon":switch(n){case"Direct":r=this.parseNormal_ByPolygon_Direct();break;case"IndexToDirect":r=this.parseNormal_ByPolygon_IndexToDirect()}}return r},c.prototype.parseNormal_ByPolygonVertex_Direct=function(e,t,r,i){return g(e,t,r,i)},c.prototype.parseNormal_ByPolygonVertex_IndexToDirect=function(e){return console.warn("not implemented"),e},c.prototype.parseNormal_ByPolygon_Direct=function(e){return console.warn("not implemented"),e},c.prototype.parseNormal_ByPolygon_IndexToDirect=function(e){return console.warn("not implemented"),e},c.prototype.parseNormal_ByVertex_Direct=function(e){return console.warn("not implemented"),e},Object.assign(h.prototype,{parse:function(e){if("LayerElementMaterial"in e.subNodes){var t=e.subNodes.LayerElementMaterial[0],r=t.properties.MappingInformationType,i=t.properties.ReferenceInformationType,n=T(t.subNodes.Materials.properties.a);switch(r){case"ByPolygon":switch(i){case"IndexToDirect":this.indexBuffer=this.parse_ByPolygon_IndexToDirect(n);break;default:this.indexBuffer=[0]}break;default:this.indexBuffer=[0]}return this.indexBuffer}},parse_ByPolygon_IndexToDirect:function(e){return e}}),l.prototype.fromNode=function(e){return this.id=e.id,this.internalId=e.id,this.times=e.subNodes.KeyTime.properties.a,this.values=e.subNodes.KeyValueFloat.properties.a,this.attrFlag=e.subNodes.KeyAttrFlags.properties.a,this.attrData=e.subNodes.KeyAttrDataFloat.properties.a,this.times=w(this.times),this.values=w(this.values),this.attrData=w(this.attrData),this.attrFlag=T(this.attrFlag),this.times=this.times.map(function(e){return E(e)}),this},l.prototype.getLength=function(){return this.times[this.times.length-1]},d.prototype.fromNode=function(e,t,r){if(this.id=t.id,this.attr=t.attrName,this.internalId=t.id,!this.attr.match(/S|R|T/))return null;for(var i in t.properties)i.match(/X/)&&(this.attrX=!0),i.match(/Y/)&&(this.attrY=!0),i.match(/Z/)&&(this.attrZ=!0);this.containerIndices=e.searchConnectionParent(this.id),this.curveIdx=e.searchConnectionChildren(this.id);for(var n=this.containerIndices.length-1;n>=0;--n){var o=r.searchRealId(this.containerIndices[n]);if(o>=0&&(this.containerBoneId=o,this.containerId=this.containerIndices[n]),o>=0)break}return this},d.prototype.setCurve=function(e){this.curves.push(e)},u.prototype.parse=function(e,t){var r=e.Objects.subNodes.AnimationCurveNode,i=e.Objects.subNodes.AnimationCurve,n=e.Objects.subNodes.AnimationLayer,o=e.Objects.subNodes.AnimationStack,s=[];for(var a in r)if(a.match(/\d+/)){var c=(new d).fromNode(e,r[a],t);s.push(c)}for(var h={},u=0;u<s.length;++u)null!==s[u]&&(h[s[u].id]=s[u]);var p=[];for(a in i)if(a.match(/\d+/)){var m=(new l).fromNode(i[a]);p.push(m);var f=e.searchConnectionParent(m.id)[0],y=e.searchConnectionType(m.id,f);if(y.match(/X/))y="x";else if(y.match(/Y/))y="y";else{if(!y.match(/Z/))continue;y="z"}h[f].curves[y]=m}for(var v in h){var g=h[v].containerBoneId;void 0===this.curves[g]&&(this.curves[g]={T:null,R:null,S:null}),this.curves[g][h[v].attr]=h[v]}this.layers={};for(var a in n){for(var _=[],E=e.searchConnectionChildren(a),u=0;u<E.length;++u)h[E[u]]&&(void 0===_[h[E[u]].containerBoneId]&&(_[h[E[u]].containerBoneId]={T:null,R:null,S:null}),_[h[E[u]].containerBoneId][h[E[u]].attr]=h[E[u]]);this.layers[a]=_}this.stacks={};for(var a in o){for(var b=[],E=e.searchConnectionChildren(a),x=0,T=Number.MAX_VALUE,u=0;u<E.length;++u)if(E[u]in this.layers){b.push(this.layers[E[u]]);for(var w=0;w<this.layers[E[u]].length;++w){var _=this.layers[E[u]][w];_&&function(e){function t(e){e.x&&(x=e.x.getLength()>x?e.x.getLength():x,T=e.x.times[0]<T?e.x.times[0]:T),e.y&&(x=e.y.getLength()>x?e.y.getLength():x,T=e.y.times[0]<T?e.y.times[0]:T),e.z&&(x=e.z.getLength()>x?e.z.getLength():x,T=e.z.times[0]<T?e.z.times[0]:T)}e.R&&t(e.R.curves),e.S&&t(e.S.curves),e.T&&t(e.T.curves)}(_)}}x>T&&(this.stacks[a]={name:o[a].attrName,layers:b,length:x-T,frames:30*(x-T)})}return this},p.prototype.add=function(e){void 0===this.textures&&(this.textures=[]),this.textures.push(e);for(var t=0;t<e.parentIds.length;++t)void 0===this.perGeoMap[e.parentIds[t]]&&(this.perGeoMap[e.parentIds[t]]=[]),this.perGeoMap[e.parentIds[t]].push(this.textures[this.textures.length-1])},p.prototype.parse=function(e){var t=e.Objects.subNodes.Texture;for(var r in t){var i=(new m).parse(t[r],e);this.textures[r]=i}return this},p.prototype.getById=function(e){return this.perGeoMap[e]},m.prototype.parse=function(e,t){return this.id=e.id,this.name=e.attrName,this.fileName=this.parseFileName(e.properties.FileName),this.parentIds=this.searchParents(this.id,t),this},m.prototype.parseFileName=function(e){if(void 0===e)return"";var t=e.split(/[\\\/]/);return t.length>0?t[t.length-1]:e},m.prototype.searchParents=function(e,t){return t.searchConnectionParent(e)},Object.assign(f.prototype,{parse:function(e){var t=e.Objects.subNodes.Material;for(var r in t){var i=(new y).parse(t[r],e);this.materials[r]=i}return this}}),Object.assign(y.prototype,{parse:function(e,t){return this.id=e.id,this.name=e.attrName,this.type=e.properties.ShadingModel,this.parameters=this.parseParameters(e.properties),this.parentIds=this.searchParents(this.id,t),this},parseParameters:function(e){var t={};return e.Diffuse&&(t.color=(new THREE.Color).fromArray([parseFloat(e.Diffuse.value.x),parseFloat(e.Diffuse.value.y),parseFloat(e.Diffuse.value.z)])),e.Specular&&(t.specular=(new THREE.Color).fromArray([parseFloat(e.Specular.value.x),parseFloat(e.Specular.value.y),parseFloat(e.Specular.value.z)])),e.Shininess&&(t.shininess=e.Shininess.value),e.Emissive&&(t.emissive=(new THREE.Color).fromArray([parseFloat(e.Emissive.value.x),parseFloat(e.Emissive.value.y),parseFloat(e.Emissive.value.z)])),e.EmissiveFactor&&(t.emissiveIntensity=e.EmissiveFactor.value),e.Reflectivity&&(t.reflectivity=e.Reflectivity.value),e.Opacity&&(t.opacity=e.Opacity.value),t.opacity<1&&(t.transparent=!0),t},searchParents:function(e,t){return t.searchConnectionParent(e)}})}()},{}],3:[function(e,t,r){t.exports=THREE.PLYLoader=function(e){this.manager=void 0!==e?e:THREE.DefaultLoadingManager,this.propertyNameMapping={}},THREE.PLYLoader.prototype={constructor:THREE.PLYLoader,load:function(e,t,r,i){var n=this,o=new THREE.XHRLoader(this.manager);o.setResponseType("arraybuffer"),o.load(e,function(e){t(n.parse(e))},r,i)},setPropertyNameMapping:function(e){this.propertyNameMapping=e},bin2str:function(e){for(var t=new Uint8Array(e),r="",i=0;i<e.byteLength;i++)r+=String.fromCharCode(t[i]);return r},isASCII:function(e){return"ascii"===this.parseHeader(this.bin2str(e)).format},parse:function(e){return e instanceof ArrayBuffer?this.isASCII(e)?this.parseASCII(this.bin2str(e)):this.parseBinary(e):this.parseASCII(e)},parseHeader:function(e){var t=/ply([\s\S]*)end_header\s/,r="",i=0,n=t.exec(e);null!==n&&(r=n[1],i=n[0].length);for(var o,s,a={comments:[],elements:[],headerLength:i},c=r.split("\n"),h=void 0,l=0;l<c.length;l++){var d=c[l];if(""!==(d=d.trim()))switch(s=d.split(/\s+/),o=s.shift(),d=s.join(" "),o){case"format":a.format=s[0],a.version=s[1];break;case"comment":a.comments.push(d);break;case"element":void 0!==h&&a.elements.push(h),h=Object(),h.name=s[0],h.count=parseInt(s[1]), | ||
h.properties=[];break;case"property":h.properties.push(function(e,t){var r={type:e[0]};return"list"===r.type?(r.name=e[3],r.countType=e[1],r.itemType=e[2]):r.name=e[1],r.name in t&&(r.name=t[r.name]),r}(s,this.propertyNameMapping));break;default:console.log("unhandled",o,s)}}return void 0!==h&&a.elements.push(h),a},parseASCIINumber:function(e,t){switch(t){case"char":case"uchar":case"short":case"ushort":case"int":case"uint":case"int8":case"uint8":case"int16":case"uint16":case"int32":case"uint32":return parseInt(e);case"float":case"double":case"float32":case"float64":return parseFloat(e)}},parseASCIIElement:function(e,t){for(var r=t.split(/\s+/),i=Object(),n=0;n<e.length;n++)if("list"===e[n].type){for(var o=[],s=this.parseASCIINumber(r.shift(),e[n].countType),a=0;a<s;a++)o.push(this.parseASCIINumber(r.shift(),e[n].itemType));i[e[n].name]=o}else i[e[n].name]=this.parseASCIINumber(r.shift(),e[n].type);return i},parseASCII:function(e){var t,r=new THREE.Geometry,i=this.parseHeader(e),n=/end_header\s([\s\S]*)$/,o="";null!==(t=n.exec(e))&&(o=t[1]);var s=o.split("\n"),a=0,c=0;r.useColor=!1;for(var h=0;h<s.length;h++){var l=s[h];if(""!==(l=l.trim())){c>=i.elements[a].count&&(a++,c=0);var d=this.parseASCIIElement(i.elements[a].properties,l);this.handleElement(r,i.elements[a].name,d),c++}}return this.postProcess(r)},postProcess:function(e){if(e.useColor){for(var t=0;t<e.faces.length;t++)e.faces[t].vertexColors=[e.colors[e.faces[t].a],e.colors[e.faces[t].b],e.colors[e.faces[t].c]];e.elementsNeedUpdate=!0}return e.computeBoundingSphere(),e},handleElement:function(e,t,r){if("vertex"===t){if(e.vertices.push(new THREE.Vector3(r.x,r.y,r.z)),"red"in r&&"green"in r&&"blue"in r){e.useColor=!0;var i=new THREE.Color;i.setRGB(r.red/255,r.green/255,r.blue/255),e.colors.push(i)}}else if("face"===t){var n=r.vertex_indices||r.vertex_index;3===n.length?e.faces.push(new THREE.Face3(n[0],n[1],n[2])):4===n.length&&e.faces.push(new THREE.Face3(n[0],n[1],n[3]),new THREE.Face3(n[1],n[2],n[3]))}},binaryRead:function(e,t,r,i){switch(r){case"int8":case"char":return[e.getInt8(t),1];case"uint8":case"uchar":return[e.getUint8(t),1];case"int16":case"short":return[e.getInt16(t,i),2];case"uint16":case"ushort":return[e.getUint16(t,i),2];case"int32":case"int":return[e.getInt32(t,i),4];case"uint32":case"uint":return[e.getUint32(t,i),4];case"float32":case"float":return[e.getFloat32(t,i),4];case"float64":case"double":return[e.getFloat64(t,i),8]}},binaryReadElement:function(e,t,r,i){for(var n,o=Object(),s=0,a=0;a<r.length;a++)if("list"===r[a].type){var c=[];n=this.binaryRead(e,t+s,r[a].countType,i);var h=n[0];s+=n[1];for(var l=0;l<h;l++)n=this.binaryRead(e,t+s,r[a].itemType,i),c.push(n[0]),s+=n[1];o[r[a].name]=c}else n=this.binaryRead(e,t+s,r[a].type,i),o[r[a].name]=n[0],s+=n[1];return[o,s]},parseBinary:function(e){for(var t,r=new THREE.Geometry,i=this.parseHeader(this.bin2str(e)),n="binary_little_endian"===i.format,o=new DataView(e,i.headerLength),s=0,a=0;a<i.elements.length;a++)for(var c=0;c<i.elements[a].count;c++){t=this.binaryReadElement(o,s,i.elements[a].properties,n),s+=t[1];var h=t[0];this.handleElement(r,i.elements[a].name,h)}return this.postProcess(r)}}},{}],4:[function(e,t,r){function i(){return"script_"+Date.now()+"_"+Math.ceil(1e5*Math.random())}function n(e,t){var r=document.createElement("script");return r.type="text/javascript",r.async=!0,r.id=t,r.src=e,r}function o(e){const t=document.getElementById(e),r=t.parentNode;try{r&&r.removeChild(t)}catch(e){}}function s(e){const t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)}function a(e,t,r){return new r(function(r,a){const c=t.timeout||5e3,h=i(),l=n(e,h),d=setTimeout(function(){a(new Error("Script request to "+e+" timed out")),o(h)},c),u=function(e){clearTimeout(e)};l.addEventListener("load",function(e){r({ok:!0}),u(d),o(h)}),l.addEventListener("error",function(t){a(new Error("Script request to "+e+" failed "+t)),u(d),o(h)}),s(l)})}function c(e){return e=e||{},function(t,r){return r=r||{},a(t,r,e.Promise||Promise)}}t.exports=c},{}],5:[function(e,t,r){function i(e){return new RegExp("^"+e.split(/\*+/).map(n).join(".*")+"$")}function n(e){return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&")}var o={once:THREE.LoopOnce,repeat:THREE.LoopRepeat,pingpong:THREE.LoopPingPong};t.exports={schema:{clip:{default:"*"},duration:{default:0},crossFadeDuration:{default:0},loop:{default:"repeat",oneOf:Object.keys(o)},repetitions:{default:1/0,min:0}},init:function(){this.model=null,this.mixer=null,this.activeActions=[];var e=this.el.getObject3D("mesh");e?this.load(e):this.el.addEventListener("model-loaded",function(e){this.load(e.detail.model)}.bind(this))},load:function(e){var t=this.el;this.model=e,this.mixer=new THREE.AnimationMixer(e),this.mixer.addEventListener("loop",function(e){t.emit("animation-loop",{action:e.action,loopDelta:e.loopDelta})}.bind(this)),this.mixer.addEventListener("finished",function(e){t.emit("animation-finished",{action:e.action,direction:e.direction})}.bind(this)),this.data.clip&&this.update({})},remove:function(){this.mixer&&this.mixer.stopAllAction()},update:function(e){e&&(this.stopAction(),this.data.clip&&this.playAction())},stopAction:function(){for(var e=this.data,t=0;t<this.activeActions.length;t++)e.crossFadeDuration?this.activeActions[t].fadeOut(e.crossFadeDuration):this.activeActions[t].stop();this.activeActions.length=0},playAction:function(){if(this.mixer){var e=this.model,t=this.data,r=e.animations||(e.geometry||{}).animations||[];if(r.length)for(var n,s=i(t.clip),a=0;n=r[a];a++)if(n.name.match(s)){var c=this.mixer.clipAction(n,e);c.enabled=!0,t.duration&&c.setDuration(t.duration),c.setLoop(o[t.loop],t.repetitions).fadeIn(t.crossFadeDuration).play(),this.activeActions.push(c)}}},tick:function(e,t){this.mixer&&!isNaN(t)&&this.mixer.update(t/1e3)}}},{}],6:[function(e,t,r){THREE.FBXLoader=e("../../lib/FBXLoader"),t.exports={schema:{src:{type:"asset"},crossorigin:{default:""}},init:function(){this.model=null},update:function(){var e,t=this.data;t.src&&(this.remove(),e=new THREE.FBXLoader,t.crossorigin&&e.setCrossOrigin(t.crossorigin),e.load(t.src,this.load.bind(this)))},load:function(e){this.model=e,this.el.setObject3D("mesh",e),this.el.emit("model-loaded",{format:"fbx",model:e})},remove:function(){this.model&&this.el.removeObject3D("mesh")}}},{"../../lib/FBXLoader":2}],7:[function(e,t,r){var i=e("../../lib/fetch-script")();t.exports.Component={schema:{type:"model"},init:function(){this.model=null,this.loader=null,this.loaderPromise=n().then(function(){this.loader=new THREE.GLTFLoader,this.loader.setCrossOrigin("Anonymous")}.bind(this))},update:function(){var e=this,t=this.el,r=this.data;r&&(this.remove(),this.loaderPromise.then(function(){this.loader.load(r,function(r){e.model=r.scene,e.model.animations=r.animations,e.system.registerModel(e.model),t.setObject3D("mesh",e.model),t.emit("model-loaded",{format:"gltf",model:e.model})})}.bind(this)))},remove:function(){this.model&&(this.el.removeObject3D("mesh"),this.system.unregisterModel(this.model))}},t.exports.System={init:function(){this.models=[]},tick:function(){var e=this.sceneEl;e.hasLoaded&&this.models.length&&THREE.GLTFLoader.Shaders.update(e.object3D,e.camera)},registerModel:function(e){this.models.push(e)},unregisterModel:function(e){var t=this.models,r=t.indexOf(e);r>=0&&t.splice(r,1)}};var n=function(){var e;return function(){return e=e||i("https://rawgit.com/mrdoob/three.js/r86/examples/js/loaders/GLTFLoader.js")}}()},{"../../lib/fetch-script":4}],8:[function(e,t,r){var i=e("../../lib/fetch-script")();void 0===THREE.PropertyBinding.sanitizeNodeName&&(THREE.PropertyBinding.sanitizeNodeName=function(e){return e.replace(/\./g,"_")}),t.exports={schema:{type:"model"},init:function(){this.model=null,this.loader=null,this.loaderPromise=n().then(function(){this.loader=new THREE.GLTF2Loader,this.loader.setCrossOrigin("Anonymous")}.bind(this))},update:function(){var e=this,t=this.el,r=this.data;r&&(this.remove(),this.loaderPromise.then(function(){this.loader.load(r,function(r){e.model=r.scene,e.model.animations=r.animations,t.setObject3D("mesh",e.model),t.emit("model-loaded",{format:"gltf",model:e.model})})}.bind(this)))},remove:function(){this.model&&this.el.removeObject3D("mesh")}};var n=function(){var e;return function(){return e=e||i("https://rawgit.com/mrdoob/three.js/r86/examples/js/loaders/GLTF2Loader.js")}}()},{"../../lib/fetch-script":4}],9:[function(e,t,r){t.exports={"animation-mixer":e("./animation-mixer"),"fbx-model":e("./fbx-model"),"gltf-model-next":e("./gltf-model-next"),"gltf-model-legacy":e("./gltf-model-legacy"),"json-model":e("./json-model"),"object-model":e("./object-model"),"ply-model":e("./ply-model"),"three-model":e("./three-model"),registerAll:function(e){this._registered||(e=e||window.AFRAME,e.components["animation-mixer"]||e.registerComponent("animation-mixer",this["animation-mixer"]),e.systems["ply-model"]||e.registerSystem("ply-model",this["ply-model"].System),e.components["ply-model"]||e.registerComponent("ply-model",this["ply-model"].Component),e.components["fbx-model"]||e.registerComponent("fbx-model",this["fbx-model"]),e.components["gltf-model-next"]||e.registerComponent("gltf-model-next",this["gltf-model-next"]),e.components["gltf-model-legacy"]||(e.registerComponent("gltf-model-legacy",this["gltf-model-legacy"].Component),e.registerSystem("gltf-model-legacy",this["gltf-model-legacy"].System)),e.components["json-model"]||e.registerComponent("json-model",this["json-model"]),e.components["object-model"]||e.registerComponent("object-model",this["object-model"]),e.components["three-model"]||e.registerComponent("three-model",this["three-model"]),this._registered=!0)}}},{"./animation-mixer":5,"./fbx-model":6,"./gltf-model-legacy":7,"./gltf-model-next":8,"./json-model":10,"./object-model":11,"./ply-model":12,"./three-model":13}],10:[function(e,t,r){t.exports={schema:{src:{type:"asset"},crossorigin:{default:""}},init:function(){this.model=null},update:function(){var e,t=this.data;t.src&&(this.remove(),e=new THREE.JSONLoader,t.crossorigin&&(e.crossOrigin=t.crossorigin),e.load(t.src,function(e,t){t.forEach(function(t){t.vertexColors=(e.faces[0]||{}).color?THREE.FaceColors:THREE.NoColors,t.skinning=!!(e.bones||[]).length,t.morphTargets=!!(e.morphTargets||[]).length,t.morphNormals=!!(e.morphNormals||[]).length});var r=(e.bones||[]).length?new THREE.SkinnedMesh(e,new THREE.MultiMaterial(t)):new THREE.Mesh(e,new THREE.MultiMaterial(t));this.load(r)}.bind(this)))},load:function(e){this.model=e,this.el.setObject3D("mesh",e),this.el.emit("model-loaded",{format:"json",model:e})},remove:function(){this.model&&this.el.removeObject3D("mesh")}}},{}],11:[function(e,t,r){t.exports={schema:{src:{type:"asset"},crossorigin:{default:""}},init:function(){this.model=null},update:function(){var e,t=this.data;t.src&&(this.remove(),e=new THREE.ObjectLoader,t.crossorigin&&e.setCrossOrigin(t.crossorigin),e.load(t.src,function(e){e.traverse(function(e){e instanceof THREE.SkinnedMesh&&e.material&&(e.material.skinning=!!(e.geometry&&e.geometry.bones||[]).length)}),this.load(e)}.bind(this)))},load:function(e){this.model=e,this.el.setObject3D("mesh",e),this.el.emit("model-loaded",{format:"json",model:e})},remove:function(){this.model&&this.el.removeObject3D("mesh")}}},{}],12:[function(e,t,r){function i(e){return new THREE.Mesh(e,new THREE.MeshPhongMaterial({color:16777215,shading:THREE.FlatShading,vertexColors:THREE.VertexColors,shininess:0}))}THREE.PLYLoader=e("../../lib/PLYLoader"),t.exports.System={init:function(){this.cache={}},getOrLoadGeometry:function(e,t){var r=this.cache,i=r[e];return!t&&i?i:(r[e]=new Promise(function(t){(new THREE.PLYLoader).load(e,function(e){t(e)})}),r[e])}},t.exports.Component={schema:{skipCache:{type:"boolean",default:!1},src:{type:"asset"}},init:function(){this.model=null},update:function(){var e=this.data,t=this.el;if(!e.src)return void console.warn("[%s] `src` property is required.",this.name);this.system.getOrLoadGeometry(e.src,e.skipCache).then(function(e){var r=i(e);t.setObject3D("mesh",r),t.emit("model-loaded",{format:"ply",model:r})})},remove:function(){this.model&&this.el.removeObject3D("mesh")}}},{"../../lib/PLYLoader":3}],13:[function(e,t,r){t.exports={deprecated:!0,schema:{src:{type:"asset"},loader:{default:"object",oneOf:["object","json"]},enableAnimation:{default:!0},animation:{default:"__auto__"},animationDuration:{default:0},crossorigin:{default:""}},init:function(){this.model=null,this.mixer=null,console.warn("[three-model] Component is deprecated. Use json-model or object-model instead.")},update:function(e){e=e||{};var t,r=this.data;if(!r.src)return void this.remove();if(Object.keys(e).length){var i=this.model&&this.model.activeAction;if(r.animation!==e.animation)return i&&i.stop(),void this.playAnimation();i&&r.enableAnimation!==i.isRunning()&&(r.enableAnimation?this.playAnimation():i.stop()),i&&r.animationDuration&&i.setDuration(r.animationDuration)}else if(this.remove(),"object"===r.loader)t=new THREE.ObjectLoader,r.crossorigin&&t.setCrossOrigin(r.crossorigin),t.load(r.src,function(e){e.traverse(function(t){t instanceof THREE.SkinnedMesh&&(e=t)}),e.material&&(e.material.skinning=!!(e.geometry&&e.geometry.bones||[]).length),this.load(e)}.bind(this));else{if("json"!==r.loader)throw new Error('[three-model] Invalid mode "%s".',r.mode);t=new THREE.JSONLoader,r.crossorigin&&(t.crossOrigin=r.crossorigin),t.load(r.src,function(e,t){t.forEach(function(t){t.vertexColors=(e.faces[0]||{}).color?THREE.FaceColors:THREE.NoColors,t.skinning=!!(e.bones||[]).length,t.morphTargets=!!(e.morphTargets||[]).length,t.morphNormals=!!(e.morphNormals||[]).length});var r=(e.bones||[]).length?new THREE.SkinnedMesh(e,new THREE.MultiMaterial(t)):new THREE.Mesh(e,new THREE.MultiMaterial(t));this.load(r)}.bind(this))}},load:function(e){this.model=e,this.mixer=new THREE.AnimationMixer(this.model),this.el.setObject3D("mesh",e),this.el.emit("model-loaded",{format:"three",model:e}),this.data.enableAnimation&&this.playAnimation()},playAnimation:function(){var e,t=this.data,r=this.model.animations||this.model.geometry.animations||[];if(t.enableAnimation&&t.animation&&r.length){if(!(e="__auto__"===t.animation?r[0]:THREE.AnimationClip.findByName(r,t.animation)))return void console.error('[three-model] Animation "%s" not found.',t.animation);this.model.activeAction=this.mixer.clipAction(e,this.model),t.animationDuration&&this.model.activeAction.setDuration(t.animationDuration),this.model.activeAction.play()}},remove:function(){this.mixer&&this.mixer.stopAllAction(),this.model&&this.el.removeObject3D("mesh")},tick:function(e,t){this.mixer&&!isNaN(t)&&this.mixer.update(t/1e3)}}},{}]},{},[1]); |
{ | ||
"name": "aframe-extras", | ||
"version": "3.9.1", | ||
"version": "3.10.0", | ||
"description": "Add-ons and examples for A-Frame VR.", | ||
@@ -5,0 +5,0 @@ "author": "Don McCurdy <dm@donmccurdy.com>", |
@@ -13,9 +13,9 @@ # A-Frame Extras | ||
```html | ||
<script src="//cdn.rawgit.com/donmccurdy/aframe-extras/v3.9.1/dist/aframe-extras.min.js"></script> | ||
<script src="//cdn.rawgit.com/donmccurdy/aframe-extras/v3.10.0/dist/aframe-extras.min.js"></script> | ||
``` | ||
CDN builds for aframe-extras/v3.9.1: | ||
CDN builds for aframe-extras/v3.10.0: | ||
- [aframe-extras.js](https://cdn.rawgit.com/donmccurdy/aframe-extras/v3.9.1/dist/aframe-extras.js) *(development)* | ||
- [aframe-extras.min.js](https://cdn.rawgit.com/donmccurdy/aframe-extras/v3.9.1/dist/aframe-extras.min.js) *(production)* | ||
- [aframe-extras.js](https://cdn.rawgit.com/donmccurdy/aframe-extras/v3.10.0/dist/aframe-extras.js) *(development)* | ||
- [aframe-extras.min.js](https://cdn.rawgit.com/donmccurdy/aframe-extras/v3.10.0/dist/aframe-extras.min.js) *(production)* | ||
@@ -28,3 +28,3 @@ For partial builds, use a subpackage like `aframe-extras.controls.min.js`. [Full list of packages below](#add-ons). | ||
|-----------|-----------------------| | ||
| v0.5.X | aframe-extras/v3.9.1 | | ||
| v0.5.X | aframe-extras/v3.10.0 | | ||
| v0.4.X | */v3.3.0 | | ||
@@ -31,0 +31,0 @@ | v0.3.X | */v2.6.1 | |
var fetchScript = require('../../lib/fetch-script')(); | ||
var LOADER_SRC = 'https://rawgit.com/mrdoob/three.js/dev/examples/js/loaders/GLTF2Loader.js'; | ||
var LOADER_SRC = 'https://rawgit.com/mrdoob/three.js/r86/examples/js/loaders/GLTF2Loader.js'; | ||
// Monkeypatch while waiting for three.js r86. | ||
@@ -15,4 +14,4 @@ if (THREE.PropertyBinding.sanitizeNodeName === undefined) { | ||
/** | ||
* Upcoming (and NOT YET STABLE) loader for glTF 2.0 models. | ||
* Pulls THREE.GLTF2Loader directly from three.js 'dev' branch. | ||
* Upcoming loader for glTF 2.0 models. | ||
* Asynchronously loads THREE.GLTF2Loader from rawgit. | ||
*/ | ||
@@ -27,2 +26,3 @@ module.exports = { | ||
this.loader = new THREE.GLTF2Loader(); | ||
this.loader.setCrossOrigin('Anonymous'); | ||
}.bind(this)); | ||
@@ -29,0 +29,0 @@ }, |
@@ -5,2 +5,3 @@ module.exports = { | ||
'gltf-model-next': require('./gltf-model-next'), | ||
'gltf-model-legacy': require('./gltf-model-legacy'), | ||
'json-model': require('./json-model'), | ||
@@ -34,3 +35,3 @@ 'object-model': require('./object-model'), | ||
// THREE.GLTF2Loader (_unstable_) | ||
// THREE.GLTF2Loader | ||
if (!AFRAME.components['gltf-model-next']) { | ||
@@ -40,2 +41,8 @@ AFRAME.registerComponent('gltf-model-next', this['gltf-model-next']); | ||
// THREE.GLTFLoader | ||
if (!AFRAME.components['gltf-model-legacy']) { | ||
AFRAME.registerComponent('gltf-model-legacy', this['gltf-model-legacy'].Component); | ||
AFRAME.registerSystem('gltf-model-legacy', this['gltf-model-legacy'].System); | ||
} | ||
// THREE.JsonLoader | ||
@@ -42,0 +49,0 @@ if (!AFRAME.components['json-model']) { |
@@ -5,3 +5,4 @@ # Loaders | ||
- **gltf-model-next**: <sub><img alt="Experimental" src="https://img.shields.io/badge/status-experimental-orange.svg"></sub> Loader for glTF 2.0 format. Hot-loads an unstable version of `THREE.GLTF2Loader` at runtime, and may change or break without warning. | ||
- **gltf-model-next**: Loader for glTF 2.0 format, planned for addition to A-Frame core with v0.7.0 release. | ||
- **gltf-model-legacy**: Loader for glTF 1.0 format, planned for _removal_ from A-Frame core with v0.7.0 release. | ||
- **json-model**: Loader for THREE.js .JSON format, generally containing a single mesh. | ||
@@ -8,0 +9,0 @@ - **object-model**: Loader for THREE.js .JSON format, generally containing multiple meshes or an entire scene. |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3129202
75
61906