!function e(t,i,n){function r(s,a){if(!i[s]){if(!t[s]){var c="function"==typeof require&&require;if(!a&&c)return c(s,!0);if(o)return o(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var h=i[s]={exports:{}};t[s][0].call(h.exports,function(e){var i=t[s][1][e];return r(i||e)},h,h.exports,e,t,i,n)}return i[s].exports}for(var o="function"==typeof require&&require,s=0;s0&&t.push(new THREE.VectorKeyframeTrack(n+".position",r,o));s.length>0&&t.push(new THREE.QuaternionKeyframeTrack(n+".quaternion",r,s));a.length>0&&t.push(new THREE.VectorKeyframeTrack(n+".scale",r,a))}(function(e,t,i){var n,r,o,s,a,c,l=ce.nodes[e.id],h=U(l.id),u=l.transforms[e.sid],d=l.matrix.clone().transpose(),p={};switch(u){case"matrix":for(o=0,s=t.array.length;o=0;){var n=e[t];if(null!==n.value[i])return n;t--}return null}(e,r,t),n=function(e,t,i){for(;t>>0));switch(i=i.toLowerCase()){case"tga":t=re;break;default:t=ne}return t}(i);if(void 0!==r){var o=r.load(i),s=e.extra;if(void 0!==s&&void 0!==s.technique&&!1===c(s.technique)){var a=s.technique;o.wrapS=a.wrapU?THREE.RepeatWrapping:THREE.ClampToEdgeWrapping,o.wrapT=a.wrapV?THREE.RepeatWrapping:THREE.ClampToEdgeWrapping,o.offset.set(a.offsetU||0,a.offsetV||0),o.repeat.set(a.repeatU||1,a.repeatV||1)}else o.wrapS=THREE.RepeatWrapping,o.wrapT=THREE.RepeatWrapping;return o}return console.warn("THREE.ColladaLoader: Loader for texture %s not found.",i),null}return console.warn("THREE.ColladaLoader: Couldn't create texture with ID:",e.id),null}var i,n=function(e){return u(ce.effects[e],T)}(e.url),r=n.profile.technique,o=n.profile.extra;switch(r.type){case"phong":case"blinn":i=new THREE.MeshPhongMaterial;break;case"lambert":i=new THREE.MeshLambertMaterial;break;default:i=new THREE.MeshBasicMaterial}i.name=e.name;var s=r.parameters;for(var a in s){var l=s[a];switch(a){case"diffuse":l.color&&i.color.fromArray(l.color),l.texture&&(i.map=t(l.texture));break;case"specular":l.color&&i.specular&&i.specular.fromArray(l.color),l.texture&&(i.specularMap=t(l.texture));break;case"bump":l.texture&&(i.normalMap=t(l.texture));break;case"ambient":l.texture&&(i.lightMap=t(l.texture));break;case"shininess":l.float&&i.shininess&&(i.shininess=l.float);break;case"emission":l.color&&i.emissive&&i.emissive.fromArray(l.color),l.texture&&(i.emissiveMap=t(l.texture))}}var h=s.transparent,d=s.transparency;if(void 0===d&&h&&(d={float:1}),void 0===h&&d&&(h={opaque:"A_ONE",data:{color:[1,1,1,1]}}),h&&d)if(h.data.texture)i.transparent=!0;else{var p=h.data.color;switch(h.opaque){case"A_ONE":i.opacity=p[3]*d.float;break;case"RGB_ZERO":i.opacity=1-p[0]*d.float;break;case"A_ZERO":i.opacity=1-p[3]*d.float;break;case"RGB_ONE":i.opacity=p[0]*d.float;break;default:console.warn('THREE.ColladaLoader: Invalid opaque type "%s" of transparent tag.',h.opaque)}i.opacity<1&&(i.transparent=!0)}return void 0!==o&&void 0!==o.technique&&1===o.technique.double_sided&&(i.side=THREE.DoubleSide),i}function x(e){return u(ce.materials[e],w)}function k(e){var t;switch(e.optics.technique){case"perspective":t=new THREE.PerspectiveCamera(e.optics.parameters.yfov,e.optics.parameters.aspect_ratio,e.optics.parameters.znear,e.optics.parameters.zfar);break;case"orthographic":var i=e.optics.parameters.ymag,n=e.optics.parameters.xmag,r=e.optics.parameters.aspect_ratio;n=void 0===n?i*r:n,i=void 0===i?n/r:i,n*=.5,i*=.5,t=new THREE.OrthographicCamera(-n,n,i,-i,e.optics.parameters.znear,e.optics.parameters.zfar);break;default:t=new THREE.PerspectiveCamera}return t.name=e.name,t}function R(e){var t=ce.cameras[e];return void 0!==t?u(t,k):(console.warn("THREE.ColladaLoader: Couldn't find camera with ID:",e),null)}function A(e){var t;switch(e.technique){case"directional":t=new THREE.DirectionalLight;break;case"point":t=new THREE.PointLight;break;case"spot":t=new THREE.SpotLight;break;case"ambient":t=new THREE.AmbientLight}return e.parameters.color&&t.color.copy(e.parameters.color),e.parameters.distance&&(t.distance=e.parameters.distance),t}function C(e){var t=ce.lights[e];return void 0!==t?u(t,A):(console.warn("THREE.ColladaLoader: Couldn't find light with ID:",e),null)}function N(e){for(var t={array:[],stride:3},o=0;o0&&t0&&u.addAttribute("position",new THREE.Float32BufferAttribute(r.array,r.stride));o.array.length>0&&u.addAttribute("normal",new THREE.Float32BufferAttribute(o.array,o.stride));c.array.length>0&&u.addAttribute("color",new THREE.Float32BufferAttribute(c.array,c.stride));s.array.length>0&&u.addAttribute("uv",new THREE.Float32BufferAttribute(s.array,s.stride));a.array.length>0&&u.addAttribute("uv2",new THREE.Float32BufferAttribute(a.array,a.stride));l.array.length>0&&u.addAttribute("skinIndex",new THREE.Float32BufferAttribute(l.array,l.stride));h.array.length>0&&u.addAttribute("skinWeight",new THREE.Float32BufferAttribute(h.array,h.stride));return n.data=u,n.type=e[0].type,n.materialKeys=d,n}(a,i,n)}return t}function H(e,t,i,n){function r(e){for(var t=o[e+i]*l,r=t+l;t4)for(var g=1,y=p-2;g<=y;g++){var E=h+0*s,f=h+s*g,m=h+s*(g+1);r(E),r(f),r(m)}h+=s*p}else for(var u=0,d=o.length;u0?c+h:c;t.inputs[u]={id:a,offset:l},t.stride=Math.max(t.stride,l+1),"TEXCOORD"===c&&(t.hasUV=!0);break;case"vcount":t.vcount=o(r.textContent);break;case"p":t.p=o(r.textContent)}}return t}(a));break;default:console.log(a)}}}ce.geometries[e.getAttribute("id")]=t}}),l(ee,"library_nodes","node",P),l(ee,"library_visual_scenes","visual_scene",function(e){var t={name:e.getAttribute("name"),children:[]};!function(e){for(var t=e.getElementsByTagName("node"),i=0;i=t.limits.max&&(t.static=!0),t.middlePosition=(t.limits.min+t.limits.max)/2,t}(n)}}return t}(n);break;case"link":t.links.push(O(n))}}}(n,t)}}ce.kinematicsModels[e.getAttribute("id")]=t}),l(ee,"library_physics_models","physics_model",function(e){for(var t={name:e.getAttribute("name")||"",rigidBodies:{}},i=0;in.limits.max||t=t.length&&t===m(e,0,t.length)}(e))g=(new s).parse(e);else{var n=m(e);if(!function(e){function t(t){var i=e[t-1];return e=e.slice(n+t),n++,i}for(var i=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"],n=0,r=0;r0,s="string"==typeof r.Content&&""!==r.Content;if(o||s){var a=this.parseImage(i[n]);t[r.RelativeFilename||r.Filename]=a}}}}for(var c in e){var l=e[c];void 0!==t[l]?e[c]=t[l]:e[c]=e[c].split("\\").pop()}return e},parseImage:function(e){var t,i=e.Content,n=e.RelativeFilename||e.Filename,r=n.slice(n.lastIndexOf(".")+1).toLowerCase();switch(r){case"bmp":t="image/bmp";break;case"jpg":case"jpeg":t="image/jpeg";break;case"png":t="image/png";break;case"tif":t="image/tiff";break;case"tga":if("function"!=typeof THREE.TGALoader)return void console.warn("FBXLoader: THREE.TGALoader is required to load TGA textures");null===THREE.Loader.Handlers.get(".tga")&&THREE.Loader.Handlers.add(/\.tga$/i,new THREE.TGALoader),t="image/tga";break;default:return void console.warn('FBXLoader: Image type "'+r+'" is not supported.')}if("string"==typeof i)return"data:"+t+";base64,"+i;var o=new Uint8Array(i);return window.URL.createObjectURL(new Blob([o],{type:t}))},parseTextures:function(e){var t=new Map;if("Texture"in g.Objects){var i=g.Objects.Texture;for(var n in i){var r=this.parseTexture(i[n],e);t.set(parseInt(n),r)}}return t},parseTexture:function(e,t){var i=this.loadTexture(e,t);i.ID=e.id,i.name=e.attrName;var n=e.WrapModeU,r=e.WrapModeV,o=void 0!==n?n.value:0,s=void 0!==r?r.value:0;if(i.wrapS=0===o?THREE.RepeatWrapping:THREE.ClampToEdgeWrapping,i.wrapT=0===s?THREE.RepeatWrapping:THREE.ClampToEdgeWrapping,"Scaling"in e){var a=e.Scaling.value;i.repeat.x=a[0],i.repeat.y=a[1]}return i},loadTexture:function(e,t){var i,n=this.textureLoader.path,r=y.get(e.id).children;void 0!==r&&r.length>0&&void 0!==t[r[0].ID]&&(0!==(i=t[r[0].ID]).indexOf("blob:")&&0!==i.indexOf("data:")||this.textureLoader.setPath(void 0));var o,s=e.FileName.slice(-3).toLowerCase();if("tga"===s){var a=THREE.Loader.Handlers.get(".tga");null===a?(console.warn("FBXLoader: TGALoader not found, creating empty placeholder texture for",i),o=new THREE.Texture):o=a.load(i)}else"psd"===s?(console.warn("FBXLoader: PSD textures are not supported, creating empty placeholder texture for",i),o=new THREE.Texture):o=this.textureLoader.load(i);return this.textureLoader.setPath(n),o},parseMaterials:function(e){var t=new Map;if("Material"in g.Objects){var i=g.Objects.Material;for(var n in i){var r=this.parseMaterial(i[n],e);null!==r&&t.set(parseInt(n),r)}}return t},parseMaterial:function(e,t){var i=e.id,n=e.attrName,o=e.ShadingModel;if("object"===(void 0===o?"undefined":r(o))&&(o=o.value),!y.has(i))return null;var s,a=this.parseParameters(e,t,i);switch(o.toLowerCase()){case"phong":s=new THREE.MeshPhongMaterial;break;case"lambert":s=new THREE.MeshLambertMaterial;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',o),s=new THREE.MeshPhongMaterial({color:3342591})}return s.setValues(a),s.name=n,s},parseParameters:function(e,t,i){var n={};e.BumpFactor&&(n.bumpScale=e.BumpFactor.value),e.Diffuse?n.color=(new THREE.Color).fromArray(e.Diffuse.value):e.DiffuseColor&&"Color"===e.DiffuseColor.type&&(n.color=(new THREE.Color).fromArray(e.DiffuseColor.value)),e.DisplacementFactor&&(n.displacementScale=e.DisplacementFactor.value),e.Emissive?n.emissive=(new THREE.Color).fromArray(e.Emissive.value):e.EmissiveColor&&"Color"===e.EmissiveColor.type&&(n.emissive=(new THREE.Color).fromArray(e.EmissiveColor.value)),e.EmissiveFactor&&(n.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),e.Opacity&&(n.opacity=parseFloat(e.Opacity.value)),n.opacity<1&&(n.transparent=!0),e.ReflectionFactor&&(n.reflectivity=e.ReflectionFactor.value),e.Shininess&&(n.shininess=e.Shininess.value),e.Specular?n.specular=(new THREE.Color).fromArray(e.Specular.value):e.SpecularColor&&"Color"===e.SpecularColor.type&&(n.specular=(new THREE.Color).fromArray(e.SpecularColor.value));var r=this;return y.get(i).children.forEach(function(e){var i=e.relationship;switch(i){case"Bump":n.bumpMap=r.getTexture(t,e.ID);break;case"DiffuseColor":n.map=r.getTexture(t,e.ID);break;case"DisplacementColor":n.displacementMap=r.getTexture(t,e.ID);break;case"EmissiveColor":n.emissiveMap=r.getTexture(t,e.ID);break;case"NormalMap":n.normalMap=r.getTexture(t,e.ID);break;case"ReflectionColor":n.envMap=r.getTexture(t,e.ID),n.envMap.mapping=THREE.EquirectangularReflectionMapping;break;case"SpecularColor":n.specularMap=r.getTexture(t,e.ID);break;case"TransparentColor":n.alphaMap=r.getTexture(t,e.ID),n.transparent=!0;break;case"AmbientColor":case"ShininessExponent":case"SpecularFactor":case"VectorDisplacementColor":default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",i)}}),n},getTexture:function(e,t){return"LayeredTexture"in g.Objects&&t in g.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=y.get(t).children[0].ID),e.get(t)},parseDeformers:function(){var e={},t={};if("Deformer"in g.Objects){var i=g.Objects.Deformer;for(var n in i){var r=i[n],o=y.get(parseInt(n));if("Skin"===r.attrType){var s=this.parseSkeleton(o,i);s.ID=n,o.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),s.geometryID=o.parents[0].ID,e[n]=s}else if("BlendShape"===r.attrType){var a={id:n};a.rawTargets=this.parseMorphTargets(o,i),a.id=n,o.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),t[n]=a}}}return{skeletons:e,morphTargets:t}},parseSkeleton:function(e,t){var i=[];return e.children.forEach(function(e){var n=t[e.ID];if("Cluster"===n.attrType){var r={ID:e.ID,indices:[],weights:[],transform:(new THREE.Matrix4).fromArray(n.Transform.a),transformLink:(new THREE.Matrix4).fromArray(n.TransformLink.a),linkMode:n.Mode};"Indexes"in n&&(r.indices=n.Indexes.a,r.weights=n.Weights.a),i.push(r)}}),{rawBones:i,bones:[]}},parseMorphTargets:function(e,t){for(var i=[],n=0;n1?o=s:s.length>0?o=s[0]:(o=new THREE.MeshPhongMaterial({color:13421772}),s.push(o)),"color"in r.attributes&&s.forEach(function(e){e.vertexColors=THREE.VertexColors}),r.FBX_Deformer?(s.forEach(function(e){e.skinning=!0}),n=new THREE.SkinnedMesh(r,o)):n=new THREE.Mesh(r,o),n},createCurve:function(e,t){var i=e.children.reduce(function(e,i){return t.has(i.ID)&&(e=t.get(i.ID)),e},null),n=new THREE.LineBasicMaterial({color:3342591,linewidth:1});return new THREE.Line(i,n)},setModelTransforms:function(e,t){var i={};"RotationOrder"in t&&(i.eulerOrder=parseInt(t.RotationOrder.value)),"Lcl_Translation"in t&&(i.translation=t.Lcl_Translation.value),"RotationOffset"in t&&(i.rotationOffset=t.RotationOffset.value),"Lcl_Rotation"in t&&(i.rotation=t.Lcl_Rotation.value),"PreRotation"in t&&(i.preRotation=t.PreRotation.value),"PostRotation"in t&&(i.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(i.scale=t.Lcl_Scaling.value);var n=d(i);e.applyMatrix(n)},setLookAtProperties:function(e,t){if("LookAtProperty"in t){y.get(e.ID).children.forEach(function(t){if("LookAtProperty"===t.relationship){var i=g.Objects.Model[t.ID];if("Lcl_Translation"in i){var n=i.Lcl_Translation.value;void 0!==e.target?(e.target.position.fromArray(n),E.add(e.target)):e.lookAt((new THREE.Vector3).fromArray(n))}}})}},bindSkeleton:function(e,t,i){var n=this.parsePoseNodes();for(var r in e){var o=e[r];y.get(parseInt(o.ID)).parents.forEach(function(e){if(t.has(e.ID)){var r=e.ID;y.get(r).parents.forEach(function(e){if(i.has(e.ID)){i.get(e.ID).bind(new THREE.Skeleton(o.bones),n[e.ID])}})}})}},parsePoseNodes:function(){var e={};if("Pose"in g.Objects){var t=g.Objects.Pose;for(var i in t)if("BindPose"===t[i].attrType){var n=t[i].PoseNode;Array.isArray(n)?n.forEach(function(t){e[t.Node]=(new THREE.Matrix4).fromArray(t.Matrix.a)}):e[n.Node]=(new THREE.Matrix4).fromArray(n.Matrix.a)}}return e},createAmbientLight:function(){if("GlobalSettings"in g&&"AmbientColor"in g.GlobalSettings){var e=g.GlobalSettings.AmbientColor.value,t=e[0],i=e[1],n=e[2];if(0!==t||0!==i||0!==n){var r=new THREE.Color(t,i,n);E.add(new THREE.AmbientLight(r,1))}}},setupMorphMaterials:function(){E.traverse(function(e){if(e.isMesh&&(e.geometry.morphAttributes.position||e.geometry.morphAttributes.normal)){var t=e.uuid,i=e.material.uuid,n=!1;E.traverse(function(e){e.isMesh&&e.material.uuid===i&&e.uuid!==t&&(n=!0)}),!0===n&&(e.material=e.material.clone()),e.material.morphTargets=!0}})}},i.prototype={constructor:i,parse:function(e){var t=new Map;if("Geometry"in g.Objects){var i=g.Objects.Geometry;for(var n in i){var r=y.get(parseInt(n)),o=this.parseGeometry(r,i[n],e);t.set(parseInt(n),o)}}return t},parseGeometry:function(e,t,i){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,i);case"NurbsCurve":return this.parseNurbsGeometry(t)}},parseMeshGeometry:function(e,t,i){var n=i.skeletons,r=i.morphTargets,o=e.parents.map(function(e){return g.Objects.Model[e.ID]});if(0!==o.length){var s=e.children.reduce(function(e,t){return void 0!==n[t.ID]&&(e=n[t.ID]),e},null),a=e.children.reduce(function(e,t){return void 0!==r[t.ID]&&(e=r[t.ID]),e},null),c=o[0],l={};"RotationOrder"in c&&(l.eulerOrder=c.RotationOrder.value),"GeometricTranslation"in c&&(l.translation=c.GeometricTranslation.value),"GeometricRotation"in c&&(l.rotation=c.GeometricRotation.value),"GeometricScaling"in c&&(l.scale=c.GeometricScaling.value);var h=d(l);return this.genGeometry(t,s,a,h)}},genGeometry:function(e,t,i,n){var r=new THREE.BufferGeometry;e.attrName&&(r.name=e.attrName);var o=this.parseGeoNode(e,t),s=this.genBuffers(o),a=new THREE.Float32BufferAttribute(s.vertex,3);if(n.applyToBufferAttribute(a),r.addAttribute("position",a),s.colors.length>0&&r.addAttribute("color",new THREE.Float32BufferAttribute(s.colors,3)),t&&(r.addAttribute("skinIndex",new THREE.Uint16BufferAttribute(s.weightsIndices,4)),r.addAttribute("skinWeight",new THREE.Float32BufferAttribute(s.vertexWeights,4)),r.FBX_Deformer=t),s.normal.length>0){var c=new THREE.Float32BufferAttribute(s.normal,3);(new THREE.Matrix3).getNormalMatrix(n).applyToBufferAttribute(c),r.addAttribute("normal",c)}if(s.uvs.forEach(function(e,t){var i="uv"+(t+1).toString();0===t&&(i="uv"),r.addAttribute(i,new THREE.Float32BufferAttribute(s.uvs[t],2))}),o.material&&"AllSame"!==o.material.mappingType){var l=s.materialIndex[0],h=0;if(s.materialIndex.forEach(function(e,t){e!==l&&(r.addGroup(h,t-h,l),l=e,h=t)}),r.groups.length>0){var u=r.groups[r.groups.length-1],d=u.start+u.count;d!==s.materialIndex.length&&r.addGroup(d,s.materialIndex.length-d,l)}0===r.groups.length&&r.addGroup(0,s.materialIndex.length,s.materialIndex[0])}return this.addMorphTargets(r,e,i,n),r},parseGeoNode:function(e,t){var i={};if(i.vertexPositions=void 0!==e.Vertices?e.Vertices.a:[],i.vertexIndices=void 0!==e.PolygonVertexIndex?e.PolygonVertexIndex.a:[],e.LayerElementColor&&(i.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(i.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(i.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){i.uv=[];for(var n=0;e.LayerElementUV[n];)i.uv.push(this.parseUVs(e.LayerElementUV[n])),n++}return i.weightTable={},null!==t&&(i.skeleton=t,t.rawBones.forEach(function(e,t){e.indices.forEach(function(n,r){void 0===i.weightTable[n]&&(i.weightTable[n]=[]),i.weightTable[n].push({id:t,weight:e.weights[r]})})})),i},genBuffers:function(e){var t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]},i=0,n=0,r=!1,o=[],s=[],a=[],c=[],l=[],h=[],d=this;return e.vertexIndices.forEach(function(p,f){var m=!1;p<0&&(p^=-1,m=!0);var v=[],g=[];if(o.push(3*p,3*p+1,3*p+2),e.color){T=u(f,i,p,e.color);a.push(T[0],T[1],T[2])}if(e.skeleton){if(void 0!==e.weightTable[p]&&e.weightTable[p].forEach(function(e){g.push(e.weight),v.push(e.id)}),g.length>4){r||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),r=!0);var y=[0,0,0,0],E=[0,0,0,0];g.forEach(function(e,t){var i=e,n=v[t];E.forEach(function(e,t,r){if(i>e){r[t]=i,i=e;var o=y[t];y[t]=n,n=o}})}),v=y,g=E}for(;g.length<4;)g.push(0),v.push(0);for(var b=0;b<4;++b)l.push(g[b]),h.push(v[b])}if(e.normal){var T=u(f,i,p,e.normal);s.push(T[0],T[1],T[2])}if(e.material&&"AllSame"!==e.material.mappingType)var w=u(f,i,p,e.material)[0];e.uv&&e.uv.forEach(function(e,t){var n=u(f,i,p,e);void 0===c[t]&&(c[t]=[]),c[t].push(n[0]),c[t].push(n[1])}),n++,m&&(d.genFace(t,e,o,w,s,a,c,l,h,n),i++,n=0,o=[],s=[],a=[],c=[],l=[],h=[])}),t},genFace:function(e,t,i,n,r,o,s,a,c,l){for(var h=2;h1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");var o=e.get(r[0].ID);i[n]={name:t[n].attrName,layer:o}}return i},addClip:function(e){var t=[],i=this;return e.layer.forEach(function(e){t=t.concat(i.generateTracks(e))}),new THREE.AnimationClip(e.name,-1,t)},generateTracks:function(e){var t=[],i=new THREE.Vector3,n=new THREE.Quaternion,r=new THREE.Vector3;if(e.transform&&e.transform.decompose(i,n,r),i=i.toArray(),n=(new THREE.Euler).setFromQuaternion(n).toArray(),r=r.toArray(),void 0!==e.T&&Object.keys(e.T.curves).length>0){var o=this.generateVectorTrack(e.modelName,e.T.curves,i,"position");void 0!==o&&t.push(o)}if(void 0!==e.R&&Object.keys(e.R.curves).length>0){var s=this.generateRotationTrack(e.modelName,e.R.curves,n,e.preRotations,e.postRotations);void 0!==s&&t.push(s)}if(void 0!==e.S&&Object.keys(e.S.curves).length>0){var a=this.generateVectorTrack(e.modelName,e.S.curves,r,"scale");void 0!==a&&t.push(a)}if(void 0!==e.DeformPercent){var c=this.generateMorphTrack(e);void 0!==c&&t.push(c)}return t},generateVectorTrack:function(e,t,i,n){var r=this.getTimesForAllAxes(t),o=this.getKeyframeTrackValues(r,t,i);return new THREE.VectorKeyframeTrack(e+"."+n,r,o)},generateRotationTrack:function(e,t,i,n,r){void 0!==t.x&&(this.interpolateRotations(t.x),t.x.values=t.x.values.map(THREE.Math.degToRad)),void 0!==t.y&&(this.interpolateRotations(t.y),t.y.values=t.y.values.map(THREE.Math.degToRad)),void 0!==t.z&&(this.interpolateRotations(t.z),t.z.values=t.z.values.map(THREE.Math.degToRad));var o=this.getTimesForAllAxes(t),s=this.getKeyframeTrackValues(o,t,i);void 0!==n&&((n=n.map(THREE.Math.degToRad)).push("ZYX"),n=(new THREE.Euler).fromArray(n),n=(new THREE.Quaternion).setFromEuler(n)),void 0!==r&&((r=r.map(THREE.Math.degToRad)).push("ZYX"),r=(new THREE.Euler).fromArray(r),r=(new THREE.Quaternion).setFromEuler(r).inverse());for(var a=new THREE.Quaternion,c=new THREE.Euler,l=[],h=0;h=180){for(var o=r/180,s=n/o,a=i+s,c=e.times[t-1],l=(e.times[t]-c)/o,h=c+l,u=[],d=[];h1&&(i=e[1].replace(/^(\w+)::/,""),n=e[2]),{id:t,name:i,type:n}},parseNodeProperty:function(e,t,i){var n=t[1].replace(/^"/,"").replace(/"$/,"").trim(),r=t[2].replace(/^"/,"").replace(/"$/,"").trim();"Content"===n&&","===r&&(r=i.replace(/"/g,"").replace(/,$/,"").trim());var o=this.getCurrentNode();if("Properties70"!==o.name){if("C"===n){var s=r.split(",").slice(1),a=parseInt(s[0]),c=parseInt(s[1]),l=r.split(",").slice(3);n="connections",function(e,t){for(var i=0,n=e.length,r=t.length;i=e.size():e.getOffset()+160+16>=e.size()},parseNode:function(e,t){var i={},n=t>=7500?e.getUint64():e.getUint32(),r=t>=7500?e.getUint64():e.getUint32(),o=(t>=7500?e.getUint64():e.getUint32(),e.getUint8()),s=e.getString(o);if(0===n)return null;for(var a=[],c=0;c0?a[0]:"",h=a.length>1?a[1]:"",u=a.length>2?a[2]:"";for(i.singleProperty=1===r&&e.getOffset()===n;n>e.getOffset();){var d=this.parseNode(e,t);null!==d&&this.parseSubNode(s,i,d)}return i.propertyList=a,"number"==typeof l&&(i.id=l),""!==h&&(i.attrName=h),""!==u&&(i.attrType=u),""!==s&&(i.name=s),i},parseSubNode:function(e,t,i){if(!0===i.singleProperty){var n=i.propertyList[0];Array.isArray(n)?(t[i.name]=i,i.a=n):t[i.name]=n}else if("Connections"===e&&"C"===i.name){var r=[];i.propertyList.forEach(function(e,t){0!==t&&r.push(e)}),void 0===t.connections&&(t.connections=[]),t.connections.push(r)}else if("Properties70"===i.name){Object.keys(i).forEach(function(e){t[e]=i[e]})}else if("Properties70"===e&&"P"===i.name){var o,s=i.propertyList[0],a=i.propertyList[1],c=i.propertyList[2],l=i.propertyList[3];0===s.indexOf("Lcl ")&&(s=s.replace("Lcl ","Lcl_")),0===a.indexOf("Lcl ")&&(a=a.replace("Lcl ","Lcl_")),o="Color"===a||"ColorRGB"===a||"Vector"===a||"Vector3D"===a||0===a.indexOf("Lcl_")?[i.propertyList[4],i.propertyList[5],i.propertyList[6]]:i.propertyList[4],t[s]={type:a,type2:c,flag:l,value:o}}else void 0===t[i.name]?"number"==typeof i.id?(t[i.name]={},t[i.name][i.id]=i):t[i.name]=i:"PoseNode"===i.name?(Array.isArray(t[i.name])||(t[i.name]=[t[i.name]]),t[i.name].push(i)):void 0===t[i.name][i.id]&&(t[i.name][i.id]=i)},parseProperty:function(e){var t=e.getString(1);switch(t){case"C":return e.getBoolean();case"D":return e.getFloat64();case"F":return e.getFloat32();case"I":return e.getInt32();case"L":return e.getInt64();case"R":i=e.getUint32();return e.getArrayBuffer(i);case"S":var i=e.getUint32();return e.getString(i);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":var n=e.getUint32(),r=e.getUint32(),o=e.getUint32();if(0===r)switch(t){case"b":case"c":return e.getBooleanArray(n);case"d":return e.getFloat64Array(n);case"f":return e.getFloat32Array(n);case"i":return e.getInt32Array(n);case"l":return e.getInt64Array(n)}"undefined"==typeof Zlib&&console.error("THREE.FBXLoader: External library Inflate.min.js required, obtain or import from https://github.com/imaya/zlib.js");var s=new a(new Zlib.Inflate(new Uint8Array(e.getArrayBuffer(o))).decompress().buffer);switch(t){case"b":case"c":return s.getBooleanArray(n);case"d":return s.getFloat64Array(n);case"f":return s.getFloat32Array(n);case"i":return s.getInt32Array(n);case"l":return s.getInt64Array(n)}default:throw new Error("THREE.FBXLoader: Unknown property type "+t)}}},a.prototype={constructor:a,getOffset:function(){return this.offset},size:function(){return this.dv.buffer.byteLength},skip:function(e){this.offset+=e},getBoolean:function(){return 1==(1&this.getUint8())},getBooleanArray:function(e){for(var t=[],i=0;i=0&&(t=t.slice(0,n)),THREE.LoaderUtils.decodeText(new Uint8Array(t))}},c.prototype={constructor:c,add:function(e,t){this[e]=t}};var b=[],T=new THREE.Matrix4,w=new THREE.Euler,x=new THREE.Vector3,k=new THREE.Vector3,R=new THREE.Matrix4;return e}()},{}],5:[function(e,t,i){"use strict";t.exports=Object.assign(function(){},{FACE_1:0,FACE_2:1,FACE_3:2,FACE_4:3,L_SHOULDER_1:4,R_SHOULDER_1:5,L_SHOULDER_2:6,R_SHOULDER_2:7,SELECT:8,START:9,DPAD_UP:12,DPAD_DOWN:13,DPAD_LEFT:14,DPAD_RIGHT:15,VENDOR:16})},{}],6:[function(e,t,i){"use strict";t.exports=function(e,t,i){this.type=e,this.index=t,this.pressed=i.pressed,this.value=i.value}},{}],7:[function(e,t,i){"use strict";t.exports={size:5,cellSize:10,extrudeSettings:{amount:1,bevelEnabled:!0,bevelSegments:1,steps:1,bevelSize:.5,bevelThickness:.5},autogenerated:!0,cells:[{q:-1,r:0,s:1,h:1,walkable:!0,userData:{}},{q:0,r:-1,s:1,h:1,walkable:!0,userData:{}},{q:0,r:0,s:0,h:1,walkable:!0,userData:{}},{q:1,r:-1,s:0,h:1,walkable:!0,userData:{}},{q:-1,r:1,s:0,h:0,walkable:!0,userData:{}},{q:0,r:1,s:-1,h:0,walkable:!0,userData:{}},{q:1,r:0,s:-1,h:0,walkable:!0,userData:{}}]}},{}],8:[function(e,t,i){"use strict";function n(e){var t=document.getElementById(e),i=t.parentNode;try{i&&i.removeChild(t)}catch(e){}}function r(e,t,i){return new i(function(i,r){var o=t.timeout||5e3,s="script_"+Date.now()+"_"+Math.ceil(1e5*Math.random()),a=function(e,t){var i=document.createElement("script");return i.type="text/javascript",i.async=!0,i.id=t,i.src=e,i}(e,s),c=setTimeout(function(){r(new Error("Script request to "+e+" timed out")),n(s)},o),l=function(e){clearTimeout(e)};a.addEventListener("load",function(e){i({ok:!0}),l(c),n(s)}),a.addEventListener("error",function(t){r(new Error("Script request to "+e+" failed "+t)),l(c),n(s)}),function(e){var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)}(a)})}t.exports=function(e){return e=e||{},function(t,i){return i=i||{},r(t,i,e.Promise||Promise)}}},{}],9:[function(e,t,i){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r="function"==typeof Symbol&&"symbol"===n(Symbol.iterator)?function(e){return void 0===e?"undefined":n(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":void 0===e?"undefined":n(e)},o=t.exports={VERSION:"0.1.1",PI:Math.PI,TAU:2*Math.PI,DEG_TO_RAD:.0174532925,RAD_TO_DEG:57.2957795,SQRT3:Math.sqrt(3),TILE:"tile",ENT:"entity",STR:"structure",HEX:"hex",SQR:"square",ABS:"abstract"};o.Board=function(e,t){if(!e)throw new Error("You must pass in a grid system for the board to use.");this.tiles=[],this.tileGroup=null,this.group=new THREE.Object3D,this.grid=null,this.overlay=null,this.finder=new o.AStarFinder(t),o.Loader.init(),this.setGrid(e)},o.Board.prototype={setEntityOnTile:function(e,t){var i=this.grid.cellToPixel(t.cell);e.position.copy(i),e.position.y+=e.heightOffset||0,e.tile&&(e.tile.entity=null),e.tile=t,t.entity=e},addTile:function(e){-1===this.tiles.indexOf(e)&&(this.tiles.push(e),this.snapTileToGrid(e),e.position.y=0,this.tileGroup.add(e.mesh),this.grid.add(e.cell),e.cell.tile=e)},removeTile:function(e){if(e){var t=this.tiles.indexOf(e);this.grid.remove(e.cell),-1!==t&&this.tiles.splice(t,1),e.dispose()}},removeAllTiles:function(){if(this.tileGroup)for(var e=this.tileGroup.children,t=0;tt;t++)i.push(this._createVertex(t));for(this.cellShape=new THREE.Shape,this.cellShape.moveTo(i[0].x,i[0].y),t=1;6>t;t++)this.cellShape.lineTo(i[t].x,i[t].y);this.cellShape.lineTo(i[0].x,i[0].y),this.cellShape.autoClose=!0,this.cellGeo=new THREE.Geometry,this.cellGeo.vertices=i,this.cellGeo.verticesNeedUpdate=!0,this.cellShapeGeo=new THREE.ShapeGeometry(this.cellShape),this._cellWidth=2*this.cellSize,this._cellLength=.5*o.SQRT3*this._cellWidth,this._hashDelimeter=".",this._directions=[new o.Cell(1,-1,0),new o.Cell(1,0,-1),new o.Cell(0,1,-1),new o.Cell(-1,1,0),new o.Cell(-1,0,1),new o.Cell(0,-1,1)],this._diagonals=[new o.Cell(2,-1,-1),new o.Cell(1,1,-2),new o.Cell(-1,2,-1),new o.Cell(-2,1,1),new o.Cell(-1,-1,2),new o.Cell(1,-2,1)],this._list=[],this._vec3=new THREE.Vector3,this._cel=new o.Cell,this._conversionVec=new THREE.Vector3,this._geoCache=[],this._matCache=[]},o.HexGrid.TWO_THIRDS=2/3,o.HexGrid.prototype={cellToPixel:function(e){return this._vec3.x=e.q*this._cellWidth*.75,this._vec3.y=e.h,this._vec3.z=-(e.s-e.r)*this._cellLength*.5,this._vec3},pixelToCell:function(e){var t=e.x*(o.HexGrid.TWO_THIRDS/this.cellSize),i=(-e.x/3+o.SQRT3/3*e.z)/this.cellSize;return this._cel.set(t,i,-t-i),this._cubeRound(this._cel)},getCellAt:function(e){var t=e.x*(o.HexGrid.TWO_THIRDS/this.cellSize),i=(-e.x/3+o.SQRT3/3*e.z)/this.cellSize;return this._cel.set(t,i,-t-i),this._cubeRound(this._cel),this.cells[this.cellToHash(this._cel)]},getNeighbors:function(e,t,i){var n,r,o=this._directions.length;for(this._list.length=0,n=0;o>n;n++)this._cel.copy(e),this._cel.add(this._directions[n]),!(r=this.cells[this.cellToHash(this._cel)])||i&&!i(e,r)||this._list.push(r);if(t)for(n=0;o>n;n++)this._cel.copy(e),this._cel.add(this._diagonals[n]),!(r=this.cells[this.cellToHash(this._cel)])||i&&!i(e,r)||this._list.push(r);return this._list},getRandomCell:function(){var e,t=0,i=o.Tools.randomInt(0,this.numCells);for(e in this.cells){if(t===i)return this.cells[e];t++}return this.cells[e]},cellToHash:function(e){return e.q+this._hashDelimeter+e.r+this._hashDelimeter+e.s},distance:function(e,t){var i=Math.max(Math.abs(e.q-t.q),Math.abs(e.r-t.r),Math.abs(e.s-t.s));return i+=t.h-e.h},clearPath:function(){var e,t;for(e in this.cells)(t=this.cells[e])._calcCost=0,t._priority=0,t._parent=null,t._visited=!1},traverse:function(e){var t;for(t in this.cells)e(this.cells[t])},generateTile:function(e,t,i){var n=Math.abs(e.h);1>n&&(n=1);var r=this._geoCache[n];r||(this.extrudeSettings.amount=n,r=new THREE.ExtrudeGeometry(this.cellShape,this.extrudeSettings),this._geoCache[n]=r);var s=new o.Tile({size:this.cellSize,scale:t,cell:e,geometry:r,material:i});return e.tile=s,s},generateTiles:function(e){e=e||{};var t=[],i={tileScale:.95,cellSize:this.cellSize,material:null,extrudeSettings:{amount:1,bevelEnabled:!0,bevelSegments:1,steps:1,bevelSize:.5,bevelThickness:.5}};i=o.Tools.merge(i,e),this.cellSize=i.cellSize,this._cellWidth=2*this.cellSize,this._cellLength=.5*o.SQRT3*this._cellWidth,this.autogenerated=!0,this.extrudeSettings=i.extrudeSettings;var n,r,s;for(n in this.cells)s=this.cells[n],(r=this.generateTile(s,i.tileScale,i.material)).position.copy(this.cellToPixel(s)),r.position.y=0,t.push(r);return t},generateTilePoly:function(e){e||(e=new THREE.MeshBasicMaterial({color:2405631}));var t=new THREE.Mesh(this.cellShapeGeo,e);return this._vec3.set(1,0,0),t.rotateOnAxis(this._vec3,o.PI/2),t},generate:function(e){e=e||{},this.size=void 0===e.size?this.size:e.size;var t,i,n,r;for(t=-this.size;tn;n++)for(r=-e;e+1>r;r++)if(s=-n-r,Math.abs(n)<=e&&Math.abs(r)<=e&&Math.abs(s)<=e){this._cel.set(n,r,s);var c=new THREE.Line(a,i);c.position.copy(this.cellToPixel(this._cel)),c.rotation.x=90*o.DEG_TO_RAD,t.add(c)}},add:function(e){var t=this.cellToHash(e);if(!this.cells[t])return this.cells[t]=e,this.numCells++,e},remove:function(e){var t=this.cellToHash(e);this.cells[t]&&(delete this.cells[t],this.numCells--)},dispose:function(){this.cells=null,this.numCells=0,this.cellShape=null,this.cellGeo.dispose(),this.cellGeo=null,this.cellShapeGeo.dispose(),this.cellShapeGeo=null,this._list=null,this._vec3=null,this._conversionVec=null,this._geoCache=null,this._matCache=null},load:function(e,t,i){var n=this;o.Tools.getJSON({url:e,callback:function(e){n.fromJSON(e),t.call(i||null,e)},cache:!1,scope:n})},fromJSON:function(e){var t,i,n=e.cells;for(this.cells={},this.numCells=0,this.size=e.size,this.cellSize=e.cellSize,this._cellWidth=2*this.cellSize,this._cellLength=.5*o.SQRT3*this._cellWidth,this.extrudeSettings=e.extrudeSettings,this.autogenerated=e.autogenerated,t=0;to&&r>s?t=-i-n:o>s?i=-t-n:n=-t-i,this._cel.set(t,i,n)}},o.HexGrid.prototype.constructor=o.HexGrid,o.SqrGrid=function(e){e=e||{},this.type=o.SQR,this.size=5,this.cellSize=void 0===e.cellSize?10:e.cellSize,this.cells={},this.numCells=0,this.extrudeSettings=null,this.autogenerated=!1;var t=[];t.push(new THREE.Vector3),t.push(new THREE.Vector3(-this.cellSize,this.cellSize)),t.push(new THREE.Vector3(this.cellSize,this.cellSize)),t.push(new THREE.Vector3(this.cellSize,-this.cellSize)),this.cellShape=new THREE.Shape,this.cellShape.moveTo(-this.cellSize,-this.cellSize),this.cellShape.lineTo(-this.cellSize,this.cellSize),this.cellShape.lineTo(this.cellSize,this.cellSize),this.cellShape.lineTo(this.cellSize,-this.cellSize),this.cellShape.lineTo(-this.cellSize,-this.cellSize),this.cellGeo=new THREE.Geometry,this.cellGeo.vertices=t,this.cellGeo.verticesNeedUpdate=!0,this.cellShapeGeo=new THREE.ShapeGeometry(this.cellShape),this._fullCellSize=2*this.cellSize,this._hashDelimeter=".",this._directions=[new o.Cell(1,0,0),new o.Cell(0,-1,0),new o.Cell(-1,0,0),new o.Cell(0,1,0)],this._diagonals=[new o.Cell(-1,-1,0),new o.Cell(-1,1,0),new o.Cell(1,1,0),new o.Cell(1,-1,0)],this._list=[],this._vec3=new THREE.Vector3,this._cel=new o.Cell,this._conversionVec=new THREE.Vector3,this._geoCache=[],this._matCache=[]},o.SqrGrid.prototype={cellToPixel:function(e){return this._vec3.x=e.q*this._fullCellSize,this._vec3.y=e.h,this._vec3.z=e.r*this._fullCellSize,this._vec3},pixelToCell:function(e){var t=Math.round(e.x/this._fullCellSize),i=Math.round(e.z/this._fullCellSize);return this._cel.set(t,i,0)},getCellAt:function(e){var t=Math.round(e.x/this._fullCellSize),i=Math.round(e.z/this._fullCellSize);return this._cel.set(t,i),this.cells[this.cellToHash(this._cel)]},getNeighbors:function(e,t,i){var n,r,o=this._directions.length;for(this._list.length=0,n=0;o>n;n++)this._cel.copy(e),this._cel.add(this._directions[n]),!(r=this.cells[this.cellToHash(this._cel)])||i&&!i(e,r)||this._list.push(r);if(t)for(n=0;o>n;n++)this._cel.copy(e),this._cel.add(this._diagonals[n]),!(r=this.cells[this.cellToHash(this._cel)])||i&&!i(e,r)||this._list.push(r);return this._list},getRandomCell:function(){var e,t=0,i=o.Tools.randomInt(0,this.numCells);for(e in this.cells){if(t===i)return this.cells[e];t++}return this.cells[e]},cellToHash:function(e){return e.q+this._hashDelimeter+e.r},distance:function(e,t){var i=Math.max(Math.abs(e.q-t.q),Math.abs(e.r-t.r));return i+=t.h-e.h},clearPath:function(){var e,t;for(e in this.cells)(t=this.cells[e])._calcCost=0,t._priority=0,t._parent=null,t._visited=!1},traverse:function(e){var t;for(t in this.cells)e(this.cells[t])},generateTile:function(e,t,i){var n=Math.abs(e.h);1>n&&(n=1);var r=this._geoCache[n];r||(this.extrudeSettings.amount=n,r=new THREE.ExtrudeGeometry(this.cellShape,this.extrudeSettings),this._geoCache[n]=r);var s=new o.Tile({size:this.cellSize,scale:t,cell:e,geometry:r,material:i});return e.tile=s,s},generateTiles:function(e){e=e||{};var t=[],i={tileScale:.95,cellSize:this.cellSize,material:null,extrudeSettings:{amount:1,bevelEnabled:!0,bevelSegments:1,steps:1,bevelSize:.5,bevelThickness:.5}};i=o.Tools.merge(i,e),this.cellSize=i.cellSize,this._fullCellSize=2*this.cellSize,this.autogenerated=!0,this.extrudeSettings=i.extrudeSettings;var n,r,s;for(n in this.cells)s=this.cells[n],(r=this.generateTile(s,i.tileScale,i.material)).position.copy(this.cellToPixel(s)),r.position.y=0,t.push(r);return t},generateTilePoly:function(e){e||(e=new THREE.MeshBasicMaterial({color:2405631}));var t=new THREE.Mesh(this.cellShapeGeo,e);return this._vec3.set(1,0,0),t.rotateOnAxis(this._vec3,o.PI/2),t},generate:function(e){e=e||{},this.size=void 0===e.size?this.size:e.size;var t,i,n,r=Math.ceil(this.size/2);for(t=-r;r>t;t++)for(i=-r;r>i;i++)n=new o.Cell(t,i+1),this.add(n)},generateOverlay:function(e,t,i){var n,r,s=Math.ceil(e/2);for(n=-s;s>n;n++)for(r=-s;s>r;r++){this._cel.set(n,r);var a=new THREE.Line(this.cellGeo,i);a.position.copy(this.cellToPixel(this._cel)),a.rotation.x=90*o.DEG_TO_RAD,t.add(a)}},add:function(e){var t=this.cellToHash(e);if(!this.cells[t])return this.cells[t]=e,this.numCells++,e},remove:function(e){var t=this.cellToHash(e);this.cells[t]&&(delete this.cells[t],this.numCells--)},dispose:function(){this.cells=null,this.numCells=0,this.cellShape=null,this.cellGeo.dispose(),this.cellGeo=null,this.cellShapeGeo.dispose(),this.cellShapeGeo=null,this._list=null,this._vec3=null,this._conversionVec=null,this._geoCache=null,this._matCache=null},load:function(e,t,i){o.Tools.getJSON({url:e,callback:function(e){this.fromJSON(e),t.call(i||null,e)},cache:!1,scope:this})},fromJSON:function(e){var t,i,n=e.cells;for(this.cells={},this.numCells=0,this.size=e.size,this.cellSize=e.cellSize,this._fullCellSize=2*this.cellSize,this.extrudeSettings=e.extrudeSettings,this.autogenerated=e.autogenerated,t=0;tt;t++)this.add(n[t])},remove:function(e){var t=this.getNode(e);return!(!t||t.free)&&(t.prev&&(t.prev.next=t.next),t.next&&(t.next.prev=t.prev),t.prev||(this.first=t.next),t.next||(this.last=t.prev),t.free=!0,t.prev=null,t.next=null,this.length--,!0)},shift:function(){var e=this.first;return 0===this.length?null:(e.prev&&(e.prev.next=e.next),e.next&&(e.next.prev=e.prev),this.first=e.next,e.next||(this.last=null),e.free=!0,e.prev=null,e.next=null,this.length--,e.obj)},pop:function(){var e=this.last;return 0===this.length?null:(e.prev&&(e.prev.next=e.next),e.next&&(e.next.prev=e.prev),this.last=e.prev,e.prev||(this.first=null),e.free=!0,e.prev=null,e.next=null,this.length--,e.obj)},concat:function(e){for(var t=e.first;t;)this.add(t.obj),t=t.next},clear:function(){for(var e=this.first;e;)e.free=!0,e=e.next;this.first=null,this.length=0},dispose:function(){for(var e=this.first;e;)e.obj=null,e=e.next;this.first=null,this.objToNodeMap=null},dump:function(e){console.log("===================="+e+"=====================");for(var t=this.first;t;)console.log("{"+t.obj.toString()+"} previous="+(t.prev?t.prev.obj:"NULL")),t=t.next();console.log("==================================="),console.log("Last: {"+(this.last?this.last.obj:"NULL")+"} First: {"+(this.first?this.first.obj:"NULL")+"}")}}).constructor=e,o.LinkedList=e}(),function(){var e=function(e,t,i,n,r){this._listener=t,this.isOnce=i,this.context=n,this.signal=e,this._priority=r||0};(e.prototype={active:!0,params:null,execute:function(e){var t,i;return this.active&&this._listener&&(i=this.params?this.params.concat(e):e,t=this._listener.apply(this.context,i),this.isOnce&&this.detach()),t},detach:function(){return this.isBound()?this.signal.remove(this._listener,this.context):null},isBound:function(){return!!this.signal&&!!this._listener},_destroy:function(){delete this.signal,delete this._listener,delete this.context},toString:function(){return"[SignalBinding isOnce:"+this.isOnce+", isBound:"+this.isBound()+", active:"+this.active+"]"}}).constructor=e;var t=function e(){this._bindings=[],this._prevParams=null;var t=this;this.dispatch=function(){e.prototype.dispatch.apply(t,arguments)}};(t.prototype={memorize:!1,_shouldPropagate:!0,active:!0,validateListener:function(e,t){if("function"!=typeof e)throw new Error("Signal: listener is a required param of {fn}() and should be a Function.".replace("{fn}",t))},_registerListener:function(t,i,n,r){var o,s=this._indexOfListener(t,n);if(-1!==s){if((o=this._bindings[s]).isOnce!==i)throw new Error("You cannot add"+(i?"":"Once")+"() then add"+(i?"Once":"")+"() the same listener without removing the relationship first.")}else o=new e(this,t,i,n,r),this._addBinding(o);return this.memorize&&this._prevParams&&o.execute(this._prevParams),o},_addBinding:function(e){var t=this._bindings.length;do{t--}while(this._bindings[t]&&e._priority<=this._bindings[t]._priority);this._bindings.splice(t+1,0,e)},_indexOfListener:function(e,t){for(var i,n=this._bindings.length;n--;)if((i=this._bindings[n])._listener===e&&i.context===t)return n;return-1},has:function(e,t){return-1!==this._indexOfListener(e,t)},add:function(e,t,i){return this.validateListener(e,"add"),this._registerListener(e,!1,t,i)},addOnce:function(e,t,i){return this.validateListener(e,"addOnce"),this._registerListener(e,!0,t,i)},remove:function(e,t){this.validateListener(e,"remove");var i=this._indexOfListener(e,t);return-1!==i&&(this._bindings[i]._destroy(),this._bindings.splice(i,1)),e},removeAll:function(e){void 0===e&&(e=null);for(var t=this._bindings.length;t--;)e?this._bindings[t].context===e&&(this._bindings[t]._destroy(),this._bindings.splice(t,1)):this._bindings[t]._destroy();e||(this._bindings.length=0)},getNumListeners:function(){return this._bindings.length},halt:function(){this._shouldPropagate=!1},dispatch:function(){if(this.active){var e,t=Array.prototype.slice.call(arguments),i=this._bindings.length;if(this.memorize&&(this._prevParams=t),i){e=this._bindings.slice(),this._shouldPropagate=!0;do{i--}while(e[i]&&this._shouldPropagate&&!1!==e[i].execute(t))}}},forget:function(){this._prevParams=null},dispose:function(){this.removeAll(),delete this._bindings,delete this._prevParams},toString:function(){return"[Signal active:"+this.active+" numListeners:"+this.getNumListeners()+"]"}}).constructor=t,o.Signal=t}(),o.AStarFinder=function(e){e=e||{};var t={allowDiagonal:!1,heuristicFilter:null};t=o.Tools.merge(t,e),this.allowDiagonal=t.allowDiagonal,this.heuristicFilter=t.heuristicFilter,this.list=new o.LinkedList},o.AStarFinder.prototype={findPath:function(e,t,i,n){var r,s,a,c,l,h;for(i=i||this.heuristicFilter,n.clearPath(),this.list.clear(),this.list.add(e);this.list.length>0;){if(this.list.sort(this.compare),r=this.list.shift(),r._visited=!0,r===t)return o.PathUtil.backtrace(t);for(l=0,h=(a=n.getNeighbors(r,this.allowDiagonal,i)).length;h>l;l++)if((c=a[l]).walkable&&(s=r._calcCost+n.distance(r,c),!c._visited||se?1:-1,o=n>t?1:-1,c=s-a;e!==i||t!==n;)u.push([e,t]),(l=2*c)>-a&&(c-=a,e+=r),s>l&&(c+=s,t+=o);return u},expandPath:function(e){var t,i,n,r,o,s,a=[],c=e.length;if(2>c)return a;for(o=0;c-1>o;++o)for(t=e[o],i=e[o+1],r=(n=this.interpolate(t[0],t[1],i[0],i[1])).length,s=0;r-1>s;++s)a.push(n[s]);return a.push(e[c-1]),a},smoothenPath:function(e,t){var i,n,r,o,s,a,c,l,h,u,d,p,f=t.length,m=t[0][0],v=t[0][1],g=t[f-1][0],y=t[f-1][1];for(s=[[i=m,n=v]],c=2;f>c;++c){for(r=(h=t[c])[0],o=h[1],u=this.interpolate(i,n,r,o),p=!1,l=1;l0?(e=i[0],t=e.object.userData.structure,this.pickedObject!=t&&(this.pickedObject&&this.signal.dispatch(o.MouseCaster.OUT,this.pickedObject),this.pickedObject=t,this.selectedObject=null,this.signal.dispatch(o.MouseCaster.OVER,this.pickedObject)),this.position.copy(e.point),this.screenPosition.z=e.distance):(this.pickedObject&&this.signal.dispatch(o.MouseCaster.OUT,this.pickedObject),this.pickedObject=null,this.selectedObject=null),this.allHits=i}},preventDefault:function(){this._preventDefault=!0},_onDocumentMouseDown:function(e){return(e=e||window.event).preventDefault(),this._preventDefault?(this._preventDefault=!1,!1):(this.pickedObject&&(this.selectedObject=this.pickedObject),this.shift=e.shiftKey,this.ctrl=e.ctrlKey,this.down=1===e.which,this.rightDown=3===e.which,void this.signal.dispatch(o.MouseCaster.DOWN,this.pickedObject))},_onDocumentMouseUp:function(e){return e.preventDefault(),this._preventDefault?(this._preventDefault=!1,!1):(this.shift=e.shiftKey,this.ctrl=e.ctrlKey,this.signal.dispatch(o.MouseCaster.UP,this.pickedObject),this.selectedObject&&this.pickedObject&&this.selectedObject.uniqueID===this.pickedObject.uniqueID&&this.signal.dispatch(o.MouseCaster.CLICK,this.pickedObject),this.down=1!==e.which&&this.down,void(this.rightDown=3!==e.which&&this.rightDown))},_onDocumentMouseMove:function(e){e.preventDefault(),this.screenPosition.x=e.clientX/window.innerWidth*2-1,this.screenPosition.y=-e.clientY/window.innerHeight*2+1},_onMouseWheel:function(e){if(this.active){e.preventDefault(),e.stopPropagation();var t=0;void 0!==e.wheelDelta?t=e.wheelDelta:void 0!==e.detail&&(t=-e.detail),t>0?this.wheel++:this.wheel--,this.signal.dispatch(o.MouseCaster.WHEEL,this.wheel)}}},o.MouseCaster.prototype.constructor=o.MouseCaster,o.Scene=function(e,t){var i={element:document.body,alpha:!0,antialias:!0,clearColor:"#fff",sortObjects:!1,fog:null,light:new THREE.DirectionalLight(16777215),lightPosition:null,cameraType:"PerspectiveCamera",cameraPosition:null,orthoZoom:4},n={minDistance:100,maxDistance:1e3,zoomSpeed:2,noZoom:!1};if(i=o.Tools.merge(i,e),"boolean"!=typeof t&&(n=o.Tools.merge(n,t)),this.renderer=new THREE.WebGLRenderer({alpha:i.alpha,antialias:i.antialias}),this.renderer.setClearColor(i.clearColor,0),this.renderer.sortObjects=i.sortObjects,this.width=window.innerWidth,this.height=window.innerHeight,this.orthoZoom=i.orthoZoom,this.container=new THREE.Scene,this.container.fog=i.fog,this.container.add(new THREE.AmbientLight(14540253)),i.lightPosition||i.light.position.set(-1,1,-1).normalize(),this.container.add(i.light),"OrthographicCamera"===i.cameraType){var r=window.innerWidth/this.orthoZoom,s=window.innerHeight/this.orthoZoom;this.camera=new THREE.OrthographicCamera(r/-2,r/2,s/2,s/-2,1,5e3)}else this.camera=new THREE.PerspectiveCamera(50,this.width/this.height,1,5e3);this.contolled=!!t,this.contolled&&(this.controls=new THREE.OrbitControls(this.camera,this.renderer.domElement),this.controls.minDistance=n.minDistance,this.controls.maxDistance=n.maxDistance,this.controls.zoomSpeed=n.zoomSpeed,this.controls.noZoom=n.noZoom),i.cameraPosition&&this.camera.position.copy(i.cameraPosition),window.addEventListener("resize",function(){if(this.width=window.innerWidth,this.height=window.innerHeight,"OrthographicCamera"===this.camera.type){var e=this.width/this.orthoZoom,t=this.height/this.orthoZoom;this.camera.left=e/-2,this.camera.right=e/2,this.camera.top=t/2,this.camera.bottom=t/-2}else this.camera.aspect=this.width/this.height;this.camera.updateProjectionMatrix(),this.renderer.setSize(this.width,this.height)}.bind(this),!1),this.attachTo(i.element)},o.Scene.prototype={attachTo:function(e){e.style.width=this.width+"px",e.style.height=this.height+"px",this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(this.width,this.height),e.appendChild(this.renderer.domElement)},add:function(e){this.container.add(e)},remove:function(e){this.container.remove(e)},render:function(){this.contolled&&this.controls.update(),this.renderer.render(this.container,this.camera)},updateOrthoZoom:function(){if(this.orthoZoom<=0)this.orthoZoom=0;else{var e=this.width/this.orthoZoom,t=this.height/this.orthoZoom;this.camera.left=e/-2,this.camera.right=e/2,this.camera.top=t/2,this.camera.bottom=t/-2,this.camera.updateProjectionMatrix()}},focusOn:function(e){this.camera.lookAt(e.position)}},o.Scene.prototype.constructor=o.Scene,o.SelectionManager=function(e){this.mouse=e,this.onSelect=new o.Signal,this.onDeselect=new o.Signal,this.selected=null,this.toggleSelection=!1,this.mouse.signal.add(this.onMouse,this)},o.SelectionManager.prototype={select:function(e,t){e&&(t=t||!0,this.selected!==e&&this.clearSelection(t),e.selected?this.toggleSelection&&(t&&this.onDeselect.dispatch(e),e.deselect()):e.select(),this.selected=e,t&&this.onSelect.dispatch(e))},clearSelection:function(e){e=e||!0,this.selected&&(e&&this.onDeselect.dispatch(this.selected),this.selected.deselect()),this.selected=null},onMouse:function(e,t){switch(e){case o.MouseCaster.DOWN:t||this.clearSelection();break;case o.MouseCaster.CLICK:this.select(t)}}},o.SelectionManager.prototype.constructor=o.SelectionManager,o.Tools={clamp:function(e,t,i){return Math.max(t,Math.min(i,e))},sign:function(e){return e&&e/Math.abs(e)},random:function(e,t){return 1===arguments.length?Math.random()*e-.5*e:Math.random()*(t-e)+e},randomInt:function(e,t){return 1===arguments.length?Math.random()*e-.5*e|0:Math.random()*(t-e+1)+e|0},normalize:function(e,t,i){return(e-t)/(i-t)},getShortRotation:function(e){return(e%=this.TAU)>this.PI?e-=this.TAU:e<-this.PI&&(e+=this.TAU),e},generateID:function(){return Math.random().toString(36).slice(2)+Date.now()},isPlainObject:function(e){if("object"!=(void 0===e?"undefined":r(e))||e.nodeType||e===e.window)return!1;try{if(e.constructor&&!Object.prototype.hasOwnProperty.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(e){return!1}return!0},merge:function(e,t){var i=this,n=Array.isArray(t),r=n&&[]||{};return n?(e=e||[],r=r.concat(e),t.forEach(function(t,n){void 0===r[n]?r[n]=t:i.isPlainObject(t)?r[n]=i.merge(e[n],t):-1===e.indexOf(t)&&r.push(t)}),r):(e&&i.isPlainObject(e)&&Object.keys(e).forEach(function(t){r[t]=e[t]}),Object.keys(t).forEach(function(n){t[n]&&i.isPlainObject(t[n])&&e[n]?r[n]=i.merge(e[n],t[n]):r[n]=t[n]}),r)},now:function(){return window.nwf?window.nwf.system.Performance.elapsedTime:window.performance.now()},empty:function(e){for(;e.lastChild;)e.removeChild(e.lastChild)},radixSort:function(e,t,i,n){if(t=t||0,i=i||e.length,n=n||31,!(t>=i-1||0>n)){for(var r=t,o=i,s=1<r;)if(e[r]&s){--o;var a=e[r];e[r]=e[o],e[o]=a}else++r;this.radixSort(e,t,o,n-1),this.radixSort(e,o,i,n-1)}},randomizeRGB:function(e,t){var i,n,r=e.split(","),o="rgb(";for(t=this.randomInt(t),i=0;3>i;i++)0>(n=parseInt(r[i])+t)?n=0:n>255&&(n=255),o+=n+",";return o=o.substring(0,o.length-1),o+=")"},getJSON:function(e){var t=new XMLHttpRequest,i=void 0!==e.cache&&e.cache?e.url:e.url+"?t="+Math.floor(1e4*Math.random())+Date.now();t.onreadystatechange=function(){if(200!==this.status)0!==this.status&&console.warn("[Tools.getJSON] Error: "+this.status+" ("+this.statusText+") :: "+e.url);else{var t=null;try{t=JSON.parse(this.responseText)}catch(e){return}e.callback.call(e.scope||null,t)}},t.open("GET",i,!0),t.setRequestHeader("Accept","application/json"),t.setRequestHeader("Content-Type","application/json"),t.send("")}}},{}],10:[function(e,t,i){"use strict";!function(e){function t(e,t){return-1!==String(e).indexOf(t)}function i(e,t,i){u!==t&&h!==t&&l!==t||Object.keys(i).forEach(function(t){e[t]=i[t]})}function n(e){var t="keyCode"in e?e.keyCode:"which"in e?e.which:0,i=function(){if(y||"keyLocation"in e){var i=y?e.location:e.keyLocation;if(i&&t in f[i])return f[i][t]}return"keyIdentifier"in e&&e.keyIdentifier in p?p[e.keyIdentifier]:t in d?d[t]:null}();if(!i)return null;var n=function(){var t=m[i.code];return t?e.shiftKey&&"shiftKey"in t?t.shiftKey:t.key:i.code}();return{code:i.code,key:n,location:i.location,keyCap:i.keyCap}}var r="KeyboardEvent"in e;r||(e.KeyboardEvent=function(){throw TypeError("Illegal constructor")}),"DOM_KEY_LOCATION_STANDARD"in e.KeyboardEvent||(e.KeyboardEvent.DOM_KEY_LOCATION_STANDARD=0),"DOM_KEY_LOCATION_LEFT"in e.KeyboardEvent||(e.KeyboardEvent.DOM_KEY_LOCATION_LEFT=1),"DOM_KEY_LOCATION_RIGHT"in e.KeyboardEvent||(e.KeyboardEvent.DOM_KEY_LOCATION_RIGHT=2),"DOM_KEY_LOCATION_NUMPAD"in e.KeyboardEvent||(e.KeyboardEvent.DOM_KEY_LOCATION_NUMPAD=3);var o=window.KeyboardEvent.DOM_KEY_LOCATION_STANDARD,s=window.KeyboardEvent.DOM_KEY_LOCATION_LEFT,a=window.KeyboardEvent.DOM_KEY_LOCATION_RIGHT,c=window.KeyboardEvent.DOM_KEY_LOCATION_NUMPAD,l=t(navigator.platform,"Win")?"win":t(navigator.platform,"Mac")?"mac":t(navigator.platform,"CrOS")?"cros":t(navigator.platform,"Linux")?"linux":t(navigator.userAgent,"iPad")||t(navigator.platform,"iPod")||t(navigator.platform,"iPhone")?"ios":"",h=t(navigator.userAgent,"Chrome/")?"chrome":t(navigator.vendor,"Apple")?"safari":t(navigator.userAgent,"MSIE")?"ie":t(navigator.userAgent,"Gecko/")?"moz":t(navigator.userAgent,"Opera/")?"opera":"",u=h+"-"+l,d={3:{code:"Cancel"},6:{code:"Help"},8:{code:"Backspace"},9:{code:"Tab"},12:{code:"Clear"},13:{code:"Enter"},16:{code:"Shift"},17:{code:"Control"},18:{code:"Alt"},19:{code:"Pause"},20:{code:"CapsLock"},21:{code:"KanaMode"},22:{code:"HangulMode"},23:{code:"JunjaMode"},24:{code:"FinalMode"},25:{code:"KanjiMode"},27:{code:"Escape"},28:{code:"Convert"},29:{code:"NonConvert"},30:{code:"Accept"},31:{code:"ModeChange"},32:{code:"Space"},33:{code:"PageUp"},34:{code:"PageDown"},35:{code:"End"},36:{code:"Home"},37:{code:"ArrowLeft"},38:{code:"ArrowUp"},39:{code:"ArrowRight"},40:{code:"ArrowDown"},41:{code:"Select"},42:{code:"Print"},43:{code:"Execute"},44:{code:"PrintScreen"},45:{code:"Insert"},46:{code:"Delete"},47:{code:"Help"},48:{code:"Digit0",keyCap:"0"},49:{code:"Digit1",keyCap:"1"},50:{code:"Digit2",keyCap:"2"},51:{code:"Digit3",keyCap:"3"},52:{code:"Digit4",keyCap:"4"},53:{code:"Digit5",keyCap:"5"},54:{code:"Digit6",keyCap:"6"},55:{code:"Digit7",keyCap:"7"},56:{code:"Digit8",keyCap:"8"},57:{code:"Digit9",keyCap:"9"},65:{code:"KeyA",keyCap:"a"},66:{code:"KeyB",keyCap:"b"},67:{code:"KeyC",keyCap:"c"},68:{code:"KeyD",keyCap:"d"},69:{code:"KeyE",keyCap:"e"},70:{code:"KeyF",keyCap:"f"},71:{code:"KeyG",keyCap:"g"},72:{code:"KeyH",keyCap:"h"},73:{code:"KeyI",keyCap:"i"},74:{code:"KeyJ",keyCap:"j"},75:{code:"KeyK",keyCap:"k"},76:{code:"KeyL",keyCap:"l"},77:{code:"KeyM",keyCap:"m"},78:{code:"KeyN",keyCap:"n"},79:{code:"KeyO",keyCap:"o"},80:{code:"KeyP",keyCap:"p"},81:{code:"KeyQ",keyCap:"q"},82:{code:"KeyR",keyCap:"r"},83:{code:"KeyS",keyCap:"s"},84:{code:"KeyT",keyCap:"t"},85:{code:"KeyU",keyCap:"u"},86:{code:"KeyV",keyCap:"v"},87:{code:"KeyW",keyCap:"w"},88:{code:"KeyX",keyCap:"x"},89:{code:"KeyY",keyCap:"y"},90:{code:"KeyZ",keyCap:"z"},91:{code:"OSLeft",location:s},92:{code:"OSRight",location:a},93:{code:"ContextMenu"},95:{code:"Standby"},96:{code:"Numpad0",keyCap:"0",location:c},97:{code:"Numpad1",keyCap:"1",location:c},98:{code:"Numpad2",keyCap:"2",location:c},99:{code:"Numpad3",keyCap:"3",location:c},100:{code:"Numpad4",keyCap:"4",location:c},101:{code:"Numpad5",keyCap:"5",location:c},102:{code:"Numpad6",keyCap:"6",location:c},103:{code:"Numpad7",keyCap:"7",location:c},104:{code:"Numpad8",keyCap:"8",location:c},105:{code:"Numpad9",keyCap:"9",location:c},106:{code:"NumpadMultiply",keyCap:"*",location:c},107:{code:"NumpadAdd",keyCap:"+",location:c},108:{code:"NumpadComma",keyCap:",",location:c},109:{code:"NumpadSubtract",keyCap:"-",location:c},110:{code:"NumpadDecimal",keyCap:".",location:c},111:{code:"NumpadDivide",keyCap:"/",location:c},112:{code:"F1"},113:{code:"F2"},114:{code:"F3"},115:{code:"F4"},116:{code:"F5"},117:{code:"F6"},118:{code:"F7"},119:{code:"F8"},120:{code:"F9"},121:{code:"F10"},122:{code:"F11"},123:{code:"F12"},124:{code:"F13"},125:{code:"F14"},126:{code:"F15"},127:{code:"F16"},128:{code:"F17"},129:{code:"F18"},130:{code:"F19"},131:{code:"F20"},132:{code:"F21"},133:{code:"F22"},134:{code:"F23"},135:{code:"F24"},144:{code:"NumLock",location:c},145:{code:"ScrollLock"},160:{code:"ShiftLeft",location:s},161:{code:"ShiftRight",location:a},162:{code:"ControlLeft",location:s},163:{code:"ControlRight",location:a},164:{code:"AltLeft",location:s},165:{code:"AltRight",location:a},166:{code:"BrowserBack"},167:{code:"BrowserForward"},168:{code:"BrowserRefresh"},169:{code:"BrowserStop"},170:{code:"BrowserSearch"},171:{code:"BrowserFavorites"},172:{code:"BrowserHome"},173:{code:"VolumeMute"},174:{code:"VolumeDown"},175:{code:"VolumeUp"},176:{code:"MediaTrackNext"},177:{code:"MediaTrackPrevious"},178:{code:"MediaStop"},179:{code:"MediaPlayPause"},180:{code:"LaunchMail"},181:{code:"MediaSelect"},182:{code:"LaunchApp1"},183:{code:"LaunchApp2"},186:{code:"Semicolon",keyCap:";"},187:{code:"Equal",keyCap:"="},188:{code:"Comma",keyCap:","},189:{code:"Minus",keyCap:"-"},190:{code:"Period",keyCap:"."},191:{code:"Slash",keyCap:"/"},192:{code:"Backquote",keyCap:"`"},219:{code:"BracketLeft",keyCap:"["},220:{code:"Backslash",keyCap:"\\"},221:{code:"BracketRight",keyCap:"]"},222:{code:"Quote",keyCap:"'"},226:{code:"IntlBackslash",keyCap:"\\"},229:{code:"Process"},246:{code:"Attn"},247:{code:"CrSel"},248:{code:"ExSel"},249:{code:"EraseEof"},250:{code:"Play"},251:{code:"ZoomToggle"},254:{code:"Clear"}};i(d,"moz",{59:{code:"Semicolon",keyCap:";"},61:{code:"Equal",keyCap:"="},107:{code:"Equal",keyCap:"="},109:{code:"Minus",keyCap:"-"},187:{code:"NumpadAdd",keyCap:"+",location:c},189:{code:"NumpadSubtract",keyCap:"-",location:c}}),i(d,"moz-mac",{12:{code:"NumLock",location:c},173:{code:"Minus",keyCap:"-"}}),i(d,"moz-win",{173:{code:"Minus",keyCap:"-"}}),i(d,"chrome-mac",{93:{code:"OSRight",location:a}}),i(d,"safari",{3:{code:"Enter"},25:{code:"Tab"}}),i(d,"ios",{10:{code:"Enter",location:o}}),i(d,"safari-mac",{91:{code:"OSLeft",location:s},93:{code:"OSRight",location:a},229:{code:"KeyQ",keyCap:"Q"}});var p={};"cros"===l&&(p["U+00A0"]={code:"ShiftLeft",location:s},p["U+00A1"]={code:"ShiftRight",location:a},p["U+00A2"]={code:"ControlLeft",location:s},p["U+00A3"]={code:"ControlRight",location:a},p["U+00A4"]={code:"AltLeft",location:s},p["U+00A5"]={code:"AltRight",location:a}),"chrome-mac"===u&&(p["U+0010"]={code:"ContextMenu"}),"safari-mac"===u&&(p["U+0010"]={code:"ContextMenu"}),"ios"===l&&(p["U+0010"]={code:"Function"},p["U+001C"]={code:"ArrowLeft"},p["U+001D"]={code:"ArrowRight"},p["U+001E"]={code:"ArrowUp"},p["U+001F"]={code:"ArrowDown"},p["U+0001"]={code:"Home"},p["U+0004"]={code:"End"},p["U+000B"]={code:"PageUp"},p["U+000C"]={code:"PageDown"});var f=[];f[s]={16:{code:"ShiftLeft",location:s},17:{code:"ControlLeft",location:s},18:{code:"AltLeft",location:s}},f[a]={16:{code:"ShiftRight",location:a},17:{code:"ControlRight",location:a},18:{code:"AltRight",location:a}},f[c]={13:{code:"NumpadEnter",location:c}},i(f[c],"moz",{109:{code:"NumpadSubtract",location:c},107:{code:"NumpadAdd",location:c}}),i(f[s],"moz-mac",{224:{code:"OSLeft",location:s}}),i(f[a],"moz-mac",{224:{code:"OSRight",location:a}}),i(f[a],"moz-win",{91:{code:"OSRight",location:a}}),i(f[a],"mac",{93:{code:"OSRight",location:a}}),i(f[c],"chrome-mac",{12:{code:"NumLock",location:c}}),i(f[c],"safari-mac",{12:{code:"NumLock",location:c},187:{code:"NumpadAdd",location:c},189:{code:"NumpadSubtract",location:c},190:{code:"NumpadDecimal",location:c},191:{code:"NumpadDivide",location:c}});var m={ShiftLeft:{key:"Shift"},ShiftRight:{key:"Shift"},ControlLeft:{key:"Control"},ControlRight:{key:"Control"},AltLeft:{key:"Alt"},AltRight:{key:"Alt"},OSLeft:{key:"OS"},OSRight:{key:"OS"},NumpadEnter:{key:"Enter"},Space:{key:" "},Digit0:{key:"0",shiftKey:")"},Digit1:{key:"1",shiftKey:"!"},Digit2:{key:"2",shiftKey:"@"},Digit3:{key:"3",shiftKey:"#"},Digit4:{key:"4",shiftKey:"$"},Digit5:{key:"5",shiftKey:"%"},Digit6:{key:"6",shiftKey:"^"},Digit7:{key:"7",shiftKey:"&"},Digit8:{key:"8",shiftKey:"*"},Digit9:{key:"9",shiftKey:"("},KeyA:{key:"a",shiftKey:"A"},KeyB:{key:"b",shiftKey:"B"},KeyC:{key:"c",shiftKey:"C"},KeyD:{key:"d",shiftKey:"D"},KeyE:{key:"e",shiftKey:"E"},KeyF:{key:"f",shiftKey:"F"},KeyG:{key:"g",shiftKey:"G"},KeyH:{key:"h",shiftKey:"H"},KeyI:{key:"i",shiftKey:"I"},KeyJ:{key:"j",shiftKey:"J"},KeyK:{key:"k",shiftKey:"K"},KeyL:{key:"l",shiftKey:"L"},KeyM:{key:"m",shiftKey:"M"},KeyN:{key:"n",shiftKey:"N"},KeyO:{key:"o",shiftKey:"O"},KeyP:{key:"p",shiftKey:"P"},KeyQ:{key:"q",shiftKey:"Q"},KeyR:{key:"r",shiftKey:"R"},KeyS:{key:"s",shiftKey:"S"},KeyT:{key:"t",shiftKey:"T"},KeyU:{key:"u",shiftKey:"U"},KeyV:{key:"v",shiftKey:"V"},KeyW:{key:"w",shiftKey:"W"},KeyX:{key:"x",shiftKey:"X"},KeyY:{key:"y",shiftKey:"Y"},KeyZ:{key:"z",shiftKey:"Z"},Numpad0:{key:"0"},Numpad1:{key:"1"},Numpad2:{key:"2"},Numpad3:{key:"3"},Numpad4:{key:"4"},Numpad5:{key:"5"},Numpad6:{key:"6"},Numpad7:{key:"7"},Numpad8:{key:"8"},Numpad9:{key:"9"},NumpadMultiply:{key:"*"},NumpadAdd:{key:"+"},NumpadComma:{key:","},NumpadSubtract:{key:"-"},NumpadDecimal:{key:"."},NumpadDivide:{key:"/"},Semicolon:{key:";",shiftKey:":"},Equal:{key:"=",shiftKey:"+"},Comma:{key:",",shiftKey:"<"},Minus:{key:"-",shiftKey:"_"},Period:{key:".",shiftKey:">"},Slash:{key:"/",shiftKey:"?"},Backquote:{key:"`",shiftKey:"~"},BracketLeft:{key:"[",shiftKey:"{"},Backslash:{key:"\\",shiftKey:"|"},BracketRight:{key:"]",shiftKey:"}"},Quote:{key:"'",shiftKey:'"'},IntlBackslash:{key:"\\",shiftKey:"|"}};i(m,"mac",{OSLeft:{key:"Meta"},OSRight:{key:"Meta"}});var v={Esc:"Escape",Nonconvert:"NonConvert",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Menu:"ContextMenu",MediaNextTrack:"MediaTrackNext",MediaPreviousTrack:"MediaTrackPrevious",SelectMedia:"MediaSelect",HalfWidth:"Hankaku",FullWidth:"Zenkaku",RomanCharacters:"Romaji",Crsel:"CrSel",Exsel:"ExSel",Zoom:"ZoomToggle"},g=function(e,t){var i={};return Object.keys(e).forEach(function(n){var r=e[n];t in r&&(i[r[t]]=r)}),i}(d,"code");try{var y=r&&"location"in new KeyboardEvent("")}catch(e){}"KeyboardEvent"in e&&"defineProperty"in Object&&function(){function e(e,t,i){t in e||Object.defineProperty(e,t,i)}if(e(KeyboardEvent.prototype,"code",{get:function(){var e=n(this);return e?e.code:""}}),"key"in KeyboardEvent.prototype){var t=Object.getOwnPropertyDescriptor(KeyboardEvent.prototype,"key");Object.defineProperty(KeyboardEvent.prototype,"key",{get:function(){var e=t.get.call(this);return v.hasOwnProperty(e)?v[e]:e}})}e(KeyboardEvent.prototype,"key",{get:function(){var e=n(this);return e&&"key"in e?e.key:"Unidentified"}}),e(KeyboardEvent.prototype,"location",{get:function(){var e=n(this);return e&&"location"in e?e.location:o}}),e(KeyboardEvent.prototype,"locale",{get:function(){return""}})}(),"queryKeyCap"in e.KeyboardEvent||(e.KeyboardEvent.queryKeyCap=function(e,t){if(e=String(e),!g.hasOwnProperty(e))return"Undefined";if(t&&"en-us"!==String(t).toLowerCase())throw Error("Unsupported locale");var i=g[e];return i.keyCap||i.code||"Undefined"}),e.identifyKey=function(e){if(!("code"in e)){var t=n(e);e.code=t?t.code:"",e.key=t&&"key"in t?t.key:"Unidentified",e.location="location"in e?e.location:"keyLocation"in e?e.keyLocation:t&&"location"in t?t.location:o,e.locale=""}}}(window)},{}],11:[function(e,t,i){var n=function(){};n.computeCentroids=function(e){var t,i,n;for(t=0,i=e.faces.length;t=0&&i.push(e)}),i.length<2)return[];i.includes(e[0])&&i.includes(e[e.length-1])&&e.push(e.shift()),i.includes(t[0])&&i.includes(t[t.length-1])&&t.push(t.shift()),i=[],e.forEach(function(e){t.includes(e)&&i.push(e)});for(var n=i[1],r=i[0],o=e.slice();o[0]!==n;)o.push(o.shift());for(var s=0,a=t.slice();a[0]!==r;)if(a.push(a.shift()),s++>10)throw new Error("Unexpected state");return a.shift(),a.pop(),o=o.concat(a)},n.setPolygonCentroid=function(e,t){var i=new THREE.Vector3,n=t.vertices;e.vertexIds.forEach(function(e){i.add(n[e])}),i.divideScalar(e.vertexIds.length),e.centroid.copy(i)},n.cleanPolygon=function(e,t){for(var i=[],n=t.vertices,r=0;rMath.PI-.01&&u0?function(e){e<0&&(n=!1)}:function(e){e>0&&(n=!1)}),n},n.distanceToSquared=function(e,t){var i=e.x-t.x,n=e.y-t.y,r=e.z-t.z;return i*i+n*n+r*r},n.isPointInPoly=function(e,t){for(var i=!1,n=-1,r=e.length,o=r-1;++nn-.5&&this.isPointInPoly(o,e))},n.triarea2=function(e,t,i){return(i.x-e.x)*(t.z-e.z)-(t.x-e.x)*(i.z-e.z)},n.vequal=function(e,t){return this.distanceToSquared(e,t)<1e-5};var r=function(e){this.content=[],this.scoreFunction=e};r.prototype.push=function(e){this.content.push(e),this.sinkDown(this.content.length-1)},r.prototype.pop=function(){var e=this.content[0],t=this.content.pop();return this.content.length>0&&(this.content[0]=t,this.bubbleUp(0)),e},r.prototype.remove=function(e){var t=this.content.indexOf(e),i=this.content.pop();t!==this.content.length-1&&(this.content[t]=i,this.scoreFunction(i)0;){var i=(e+1>>1)-1,n=this.content[i];if(!(this.scoreFunction(t)0;){var r=n.pop();if(r===i){for(var o=r,s=[];o.parent;)s.push(o),o=o.parent;return this.cleanUp(s),s.reverse()}r.closed=!0;for(var a=this.neighbours(e,r),c=0,l=a.length;c0)){o.push(t),t=e=t,i=e,a=s=a,c=s,l=s;continue}i=u,c=l}if(n.triarea2(e,t,h)>=0){if(!(n.vequal(e,t)||n.triarea2(e,i,h)<0)){o.push(i),t=e=i,i=e,a=s=c,c=s,l=s;continue}t=h,a=l}}return 0!==o.length&&n.vequal(o[o.length-1],r[r.length-1].left)||o.push(r[r.length-1].left),this.path=o,o};var l,h,u,d,p,f,m=function(){this.zones={}};m.createZone=function(e){return a.buildZone(e)},m.prototype.setZoneData=function(e,t){this.zones[e]=t},m.prototype.getGroup=function(e,t){if(!this.zones[e])return null;var i=null,r=Math.pow(50,2);return this.zones[e].groups.forEach(function(e,o){e.forEach(function(e){var s=n.distanceToSquared(e.centroid,t);s2))for(var y=0;y.2||Math.abs(n)>.2},getVelocityDelta:function(){var e=this._dpadVector,t=this._moveVector;this.getDpad(e),this.getJoystick(o.MOVEMENT,t);var i=e.x||t.x,n=e.y||t.y,r=new THREE.Vector3;return Math.abs(i)>.2&&(r.x+=i),Math.abs(n)>.2&&(r.z+=n),r},isRotationActive:function(){if(!this.data.enabled||!this.isConnected())return!1;var e=this._lookVector;return this.getJoystick(o.ROTATION,e),Math.abs(e.x)>.2||Math.abs(e.y)>.2},updateRotation:function(e){if(this.isRotationActive()){var t=this.data,i=this.yaw,n=this.pitch,r=t.camera.components["look-controls"],s=r&&r.pitchObject&&r.yawObject;s&&(n.rotation.copy(r.pitchObject.rotation),i.rotation.copy(r.yawObject.rotation));var a=this._lookVector;this.getJoystick(o.ROTATION,a),Math.abs(a.x)<=.2&&(a.x=0),Math.abs(a.y)<=.2&&(a.y=0),a.multiplyScalar(t.rotationSensitivity*e/1e3),i.rotation.y-=a.x,n.rotation.x-=a.y,n.rotation.x=Math.max(-Math.PI/2,Math.min(Math.PI/2,n.rotation.x)),t.camera.object3D.rotation.set(n.rotation.x,i.rotation.y,0),s&&(r.pitchObject.rotation.copy(n.rotation),r.yawObject.rotation.copy(i.rotation))}},updateButtonState:function(){var e=this.getGamepad();if(this.data.enabled&&e)for(var t=0;t.2?c.set(0,0,0):this.updateVelocity(r),s.constrainToNavMesh&&!1!==a.isNavMeshConstrained){if(c.lengthSq()<1e-5)return;e.copy(o.object3D.position),t.copy(c).multiplyScalar(r/1e3).add(e);var l=o.sceneEl.systems.nav;this.navGroup=null===this.navGroup?l.getGroup(e):this.navGroup,this.navNode=this.navNode||l.getNode(e,this.navGroup),this.navNode=l.clampStep(e,t,this.navGroup,this.navNode,i),o.object3D.position.copy(i)}else o.hasAttribute("velocity")?o.setAttribute("velocity",c):(o.object3D.position.x+=c.x*r/1e3,o.object3D.position.y+=c.y*r/1e3,o.object3D.position.z+=c.z*r/1e3)}}}}(),updateVelocityCtrl:function(){var e=this.data;if(e.enabled){for(var t=0,i=e.controls.length;t0){var n=0,r=0;t.enableNegX&&i[0]this.startingAxisData[0]&&(n=1),t.enablePosZ&&i[1]>this.startingAxisData[1]&&(r=-1),t.enableNegZ&&i[1]o?(this.zVel=0,this.xVel=n,this.isMoving=!0):(this.xVel=0,this.zVel=r,this.isMoving=!0)}},handleTouchAxis:function(e){var t=this.data,i=e.detail.axis,n=0,r=0;t.enableNegX&&i[0]<0&&(n=-1),t.enablePosX&&i[0]>0&&(n=1),t.enablePosZ&&i[1]>0&&(r=-1),t.enableNegZ&&i[1]<0&&(r=1),Math.abs(i[0])>Math.abs(i[1])?(this.zVel=0,this.xVel=n):(this.xVel=0,this.zVel=r)}})},{}],19:[function(e,t,i){"use strict";function n(e){return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&")}var r={once:THREE.LoopOnce,repeat:THREE.LoopRepeat,pingpong:THREE.LoopPingPong};t.exports=AFRAME.registerComponent("animation-mixer",{schema:{clip:{default:"*"},duration:{default:0},clampWhenFinished:{default:!1,type:"boolean"},crossFadeDuration:{default:0},loop:{default:"repeat",oneOf:Object.keys(r)},repetitions:{default:1/0,min:0},timeScale:{default:1}},init:function(){var e=this;this.model=null,this.mixer=null,this.activeActions=[];var t=this.el.getObject3D("mesh");t?this.load(t):this.el.addEventListener("model-loaded",function(t){e.load(t.detail.model)})},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})}),this.mixer.addEventListener("finished",function(e){t.emit("animation-finished",{action:e.action,direction:e.direction})}),this.data.clip&&this.update({})},remove:function(){this.mixer&&this.mixer.stopAllAction()},update:function(e){if(e){var t=this.data,i=AFRAME.utils.diff(t,e);if("clip"in i)return this.stopAction(),void(t.clip&&this.playAction());this.activeActions.forEach(function(e){"duration"in i&&t.duration&&e.setDuration(t.duration),"clampWhenFinished"in i&&(e.clampWhenFinished=t.clampWhenFinished),("loop"in i||"repetitions"in i)&&e.setLoop(r[t.loop],t.repetitions),"timeScale"in i&&e.setEffectiveTimeScale(t.timeScale)})}},stopAction:function(){for(var e=this.data,t=0;t0&&this.el.emit("jumpend"),this.numJumps=0}})},{}],30:[function(e,t,i){"use strict";t.exports=AFRAME.registerComponent("kinematic-body",{dependencies:["velocity"],schema:{mass:{default:5},radius:{default:1.3},linearDamping:{default:.05},enableSlopes:{default:!0},enableJumps:{default:!1}},init:function(){this.system=this.el.sceneEl.systems.physics,this.system.addComponent(this);var e=this.el,t=this.data,i=(new CANNON.Vec3).copy(e.object3D.getWorldPosition(new THREE.Vector3));this.body=new CANNON.Body({material:this.system.getMaterial("staticMaterial"),position:i,mass:t.mass,linearDamping:t.linearDamping,fixedRotation:!0}),this.body.addShape(new CANNON.Sphere(t.radius),new CANNON.Vec3(0,t.radius,0)),this.body.el=this.el,this.el.body=this.body,this.system.addBody(this.body),e.hasAttribute("wasd-controls")&&console.warn("[kinematic-body] Not compatible with wasd-controls, use movement-controls.")},remove:function(){this.system.removeBody(this.body),this.system.removeComponent(this),delete this.el.body},beforeStep:function(e,t){if(t){var i=this.el,n=this.data,r=this.body;n.enableJumps||r.velocity.set(0,0,0),r.position.copy(i.getAttribute("position"))}},step:function(){var e=new THREE.Vector3,t=new THREE.Vector3,i=new THREE.Vector3,n=new THREE.Vector3;return function(r,o){if(o){var s=this.body,a=this.data,c=void 0,l=-1/0,h=void 0,u=this.system.getContacts();o=Math.min(o,1e3*this.system.data.maxInterval),n.set(0,0,0),e.copy(this.el.getAttribute("velocity")),s.velocity.copy(e);for(var d,p=0;d=u[p];p++)if(d.enabled){if(s.id===d.bi.id)d.ni.negate(i);else{if(s.id!==d.bj.id)continue;i.copy(d.ni)}s.velocity.dot(i)<-1e-6&&i.y<=.5?e.projectOnPlane(i):i.y>.5&&(c=s.id===d.bi.id?Math.abs(d.rj.y+d.bj.position.y):Math.abs(d.ri.y+d.bi.position.y))>l&&(l=c,n.copy(i),h=s.id===d.bi.id?d.bj:d.bi)}t.copy(e).normalize(),h&&(!a.enableJumps||t.y<.5)?(a.enableSlopes?n.y<1-1e-6&&n.copy(this.raycastToGround(h,n)):n.set(0,1,0),e.projectOnPlane(n)):this.system.driver.world&&e.add(this.system.driver.world.gravity.scale(4*o/1e3)),s.velocity.copy(e),this.el.setAttribute("velocity",s.velocity),this.el.setAttribute("position",s.position)}}}(),raycastToGround:function(e,t){var i=void 0,n=void 0,r=this.body.position,o=this.body.position.clone();return(i=new CANNON.Ray(r,o))._updateDirection(),i.intersectBody(e),i.hasHit?(n=i.result.hitNormalWorld,Math.abs(n.y)>Math.abs(t.y)?n:t):t}})},{}],31:[function(e,t,i){"use strict";t.exports=AFRAME.registerComponent("mesh-smooth",{init:function(){this.el.addEventListener("model-loaded",function(e){e.detail.model.traverse(function(e){e.isMesh&&e.geometry.computeVertexNormals()})})}})},{}],32:[function(e,t,i){"use strict";t.exports=AFRAME.registerComponent("normal-material",{init:function(){this.material=new THREE.MeshNormalMaterial({flatShading:!0}),this.applyMaterial=this.applyMaterial.bind(this),this.el.addEventListener("object3dset",this.applyMaterial)},remove:function(){this.el.removeEventListener("object3dset",this.applyMaterial)},applyMaterial:function(){var e=this;this.el.object3D.traverse(function(t){t.isMesh&&(t.material=e.material)})}})},{}],33:[function(e,t,i){"use strict";t.exports=AFRAME.registerComponent("sphere-collider",{schema:{objects:{default:""},state:{default:"collided"},radius:{default:.05},watch:{default:!0}},init:function(){this.observer=null,this.els=[],this.collisions=[],this.handleHit=this.handleHit.bind(this),this.handleHitEnd=this.handleHitEnd.bind(this)},remove:function(){this.pause()},play:function(){var e=this.el.sceneEl;this.data.watch&&(this.observer=new MutationObserver(this.update.bind(this,null)),this.observer.observe(e,{childList:!0,subtree:!0}))},pause:function(){this.observer&&(this.observer.disconnect(),this.observer=null)},update:function(){var e=this.data,t=void 0;t=e.objects?this.el.sceneEl.querySelectorAll(e.objects):this.el.sceneEl.children,this.els=Array.prototype.slice.call(t)},tick:function(){var e=new THREE.Vector3,t=new THREE.Vector3,i=new THREE.Vector3,n=new THREE.Vector3,r=new THREE.Box3,o=new Map;return function(){var s=this.el,a=this.data,c=[],l=void 0;s.getObject3D("mesh")&&(o.clear(),s.object3D.getWorldPosition(e),s.object3D.getWorldScale(i),l=a.radius*function(e){return Math.max.apply(null,e.toArray())}(i),this.els.forEach(function(i){var s=void 0,a=void 0,h=void 0,u=void 0;i.isEntity&&(a=i.getObject3D("mesh"))&&(r.setFromObject(a).getSize(n),u=Math.max(n.x,n.y,n.z)/2,s=Math.sqrt(2*u*u),r.getCenter(t),s&&(h=e.distanceTo(t))o.get(t)?1:-1}).forEach(this.handleHit),0===c.length&&s.emit("hit",{el:null}),this.collisions.filter(function(e){return!o.has(e)}).forEach(this.handleHitEnd),this.collisions=c)}}(),handleHit:function(e){e.emit("hit"),e.addState(this.data.state),this.el.emit("hit",{el:e})},handleHitEnd:function(e){e.emit("hitend"),e.removeState(this.data.state),this.el.emit("hitend",{el:e})}})},{}],34:[function(e,t,i){"use strict";e("./nav-mesh"),e("./nav-agent"),e("./system")},{"./nav-agent":35,"./nav-mesh":36,"./system":37}],35:[function(e,t,i){"use strict";t.exports=AFRAME.registerComponent("nav-agent",{schema:{destination:{type:"vec3"},active:{default:!1},speed:{default:2}},init:function(){this.system=this.el.sceneEl.systems.nav,this.system.addAgent(this),this.group=null,this.path=[],this.raycaster=new THREE.Raycaster},remove:function(){this.system.removeAgent(this)},update:function(){this.path.length=0},updateNavLocation:function(){this.group=null,this.path=[]},tick:function(){var e=new THREE.Vector3,t=new THREE.Vector3,i=new THREE.Vector3;return function(n,r){var o=this.el,s=this.data,a=this.raycaster,c=s.speed*r/1e3;if(s.active){if(!this.path.length){var l=this.el.object3D.position;this.group=this.group||this.system.getGroup(l),this.path=this.system.getPath(l,e.copy(s.destination),this.group)||[],o.emit("navigation-start")}if(!this.path.length)return console.warn("[nav] Unable to find path to %o.",s.destination),this.el.setAttribute("nav-agent",{active:!1}),void o.emit("navigation-end");var h=o.object3D.position,u=this.path[0];t.subVectors(u,h);var d=void 0;if(t.length()