!function e(t,i,n){function o(s,a){if(!i[s]){if(!t[s]){var c="function"==typeof require&&require;if(!a&&c)return c(s,!0);if(r)return r(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 o(i||e)},h,h.exports,e,t,i,n)}return i[s].exports}for(var r="function"==typeof require&&require,s=0;s0,a="string"==typeof r.Content&&""!==r.Content;if(s||a){var c=function(e){var t,i=e.Content,n=e.RelativeFilename||e.Filename,o=n.slice(n.lastIndexOf(".")+1).toLowerCase();switch(o){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;default:return void console.warn('FBXLoader: Image type "'+o+'" is not supported.')}if("string"==typeof i)return"data:"+t+";base64,"+i;var r=new Uint8Array(i);return window.URL.createObjectURL(new Blob([r],{type:t}))}(n[o]);i[r.Filename]=c}}}}for(var l in t){var h=t[l];void 0!==i[h]?t[l]=i[h]:t[l]=t[l].split("\\").pop()}return t}function i(e,t,i,n){var o=new Map;if("Texture"in e.Objects){var r=e.Objects.Texture;for(var s in r){var a=function(e,t,i,n){var o=function(e,t,i,n){var o,r=t.path,s=n.get(e.id).children;void 0!==s&&s.length>0&&void 0!==i[s[0].ID]&&(0!==(o=i[s[0].ID]).indexOf("blob:")&&0!==o.indexOf("data:")||t.setPath(void 0));var a=t.load(o);return t.setPath(r),a}(e,t,i,n);o.ID=e.id,o.name=e.attrName;var r=e.WrapModeU,s=e.WrapModeV,a=void 0!==r?r.value:0,c=void 0!==s?s.value:0;if(o.wrapS=0===a?THREE.RepeatWrapping:THREE.ClampToEdgeWrapping,o.wrapT=0===c?THREE.RepeatWrapping:THREE.ClampToEdgeWrapping,"Scaling"in e){var l=e.Scaling.value;o.repeat.x=l[0],o.repeat.y=l[1]}return o}(r[s],t,i,n);o.set(parseInt(s),a)}}return o}function n(e,t,i){var n=new Map;if("Material"in e.Objects){var s=e.Objects.Material;for(var a in s){var c=function(e,t,i,n){var s=t.id,a=t.attrName,c=t.ShadingModel;"object"===(void 0===c?"undefined":o(c))&&(c=c.value);if(!n.has(s))return null;var l,h=function(e,t,i,n,o){var s={};t.BumpFactor&&(s.bumpScale=t.BumpFactor.value);t.Diffuse&&(s.color=(new THREE.Color).fromArray(t.Diffuse.value));t.DisplacementFactor&&(s.displacementScale=t.DisplacementFactor.value);t.ReflectionFactor&&(s.reflectivity=t.ReflectionFactor.value);t.Specular&&(s.specular=(new THREE.Color).fromArray(t.Specular.value));t.Shininess&&(s.shininess=t.Shininess.value);t.Emissive&&(s.emissive=(new THREE.Color).fromArray(t.Emissive.value));t.EmissiveFactor&&(s.emissiveIntensity=parseFloat(t.EmissiveFactor.value));t.Opacity&&(s.opacity=parseFloat(t.Opacity.value));s.opacity<1&&(s.transparent=!0);return o.get(n).children.forEach(function(t){var n=t.relationship;switch(n){case"Bump":s.bumpMap=i.get(t.ID);break;case"DiffuseColor":s.map=r(e,i,t.ID,o);break;case"DisplacementColor":s.displacementMap=r(e,i,t.ID,o);break;case"EmissiveColor":s.emissiveMap=r(e,i,t.ID,o);break;case"NormalMap":s.normalMap=r(e,i,t.ID,o);break;case"ReflectionColor":s.envMap=r(e,i,t.ID,o),s.envMap.mapping=THREE.EquirectangularReflectionMapping;break;case"SpecularColor":s.specularMap=r(e,i,t.ID,o);break;case"TransparentColor":s.alphaMap=r(e,i,t.ID,o),s.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.",n)}}),s}(e,t,i,s,n);switch(c.toLowerCase()){case"phong":l=new THREE.MeshPhongMaterial;break;case"lambert":l=new THREE.MeshLambertMaterial;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',c),l=new THREE.MeshPhongMaterial({color:3342591})}return l.setValues(h),l.name=a,l}(e,s[a],t,i);null!==c&&n.set(parseInt(a),c)}}return n}function r(e,t,i,n){return"LayeredTexture"in e.Objects&&i in e.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),i=n.get(i).children[0].ID),t.get(i)}function s(e,t){var i={};if("Deformer"in e.Objects){var n=e.Objects.Deformer;for(var o in n){if("Skin"===n[o].attrType){var r=t.get(parseInt(o)),s=function(e,t){var i=[];return e.children.forEach(function(e){var n=t[e.ID];if("Cluster"===n.attrType){var o={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&&(o.indices=n.Indexes.a,o.weights=n.Weights.a),i.push(o)}}),{rawBones:i,bones:[]}}(r,n);s.ID=o,r.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),s.geometryID=r.parents[0].ID,i[o]=s}}}return i}function a(e,t,i){var n=new Map;if("Geometry"in e.Objects){var o=e.Objects.Geometry;for(var r in o){var s=function(e,t,i,n){switch(i.attrType){case"Mesh":return function(e,t,i,n){var o=t.parents.map(function(t){return e.Objects.Model[t.ID]});if(0===o.length)return;var r=t.children.reduce(function(e,t){return void 0!==n[t.ID]&&(e=n[t.ID]),e},null),s=new THREE.Matrix4,a=o[0];if("GeometricRotation"in a){var l=a.GeometricRotation.value.map(THREE.Math.degToRad);l[3]="ZYX",s.makeRotationFromEuler((new THREE.Euler).fromArray(l))}"GeometricTranslation"in a&&s.setPosition((new THREE.Vector3).fromArray(a.GeometricTranslation.value));return function(e,t,i,n,o){var r=i.Vertices.a,s=i.PolygonVertexIndex.a,a=[],l=[],h=[],u=[],d=[],p=[],f=[];if(i.LayerElementColor)var v=function(e){var t=e.MappingInformationType,i=e.ReferenceInformationType,n=e.Colors.a,o=[];"IndexToDirect"===i&&(o=e.ColorIndex.a);return{dataSize:4,buffer:n,indices:o,mappingType:t,referenceType:i}}(i.LayerElementColor[0]);if(i.LayerElementMaterial)var m=function(e){var t=e.MappingInformationType,i=e.ReferenceInformationType;if("NoMappingInformation"===t)return{dataSize:1,buffer:[0],indices:[0],mappingType:"AllSame",referenceType:i};for(var n=e.Materials.a,o=[],r=0;r4){k||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),k=!0);var D=[0,0,0,0],L=[0,0,0,0];E.forEach(function(e,t){var i=e,n=o[t];L.forEach(function(e,t,o){if(i>e){o[t]=i,i=e;var r=D[t];D[t]=n,n=r}})}),o=D,E=L}for(;E.length<4;)E.push(0),o.push(0);for(H=0;H<4;++H)M.push(E[H]),A.push(o[H])}if(y){var O=c(t,w,e,y);C.push(O[0],O[1],O[2])}if(m&&"AllSame"!==m.mappingType)var _=c(t,w,e,m)[0];if(g&&g.forEach(function(i,n){var o=c(t,w,e,i);void 0===R[n]&&(R[n]=[]),R[n].push(o[0]),R[n].push(o[1])}),T++,i){for(var H=2;H0&&D.addAttribute("color",new THREE.Float32BufferAttribute(h,3));n&&(D.addAttribute("skinIndex",new THREE.Float32BufferAttribute(f,4)),D.addAttribute("skinWeight",new THREE.Float32BufferAttribute(p,4)),D.FBX_Deformer=n);if(l.length>0){var O=new THREE.Float32BufferAttribute(l,3);(new THREE.Matrix3).getNormalMatrix(o).applyToBufferAttribute(O),D.addAttribute("normal",O)}if(u.forEach(function(e,t){var i="uv"+(t+1).toString();0===t&&(i="uv"),D.addAttribute(i,new THREE.Float32BufferAttribute(u[t],2))}),m&&"AllSame"!==m.mappingType){var _=d[0],H=0;if(d.forEach(function(e,t){e!==_&&(D.addGroup(H,t-H,_),_=e,H=t)}),D.groups.length>0){var N=D.groups[D.groups.length-1],I=N.start+N.count;I!==d.length&&D.addGroup(I,d.length-I,_)}0===D.groups.length&&D.addGroup(0,d.length,d[0])}return D}(0,0,i,r,s)}(e,t,i,n);case"NurbsCurve":return function(e){if(void 0===THREE.NURBSCurve)return console.error("THREE.FBXLoader: The loader relies on THREE.NURBSCurve for any nurbs present in the model. Nurbs will show up as empty geometry."),new THREE.BufferGeometry;var t=parseInt(e.Order);if(isNaN(t))return console.error("THREE.FBXLoader: Invalid Order %s given for geometry ID: %s",e.Order,e.id),new THREE.BufferGeometry;for(var i=t-1,n=e.KnotVector.a,o=[],r=e.Points.a,s=0,a=r.length;s1?s=a:a.length>0?s=a[0]:(s=new THREE.MeshPhongMaterial({color:13421772}),a.push(s));"color"in r.attributes&&a.forEach(function(e){e.vertexColors=THREE.VertexColors});r.FBX_Deformer?(a.forEach(function(e){e.skinning=!0}),o=new THREE.SkinnedMesh(r,s)):o=new THREE.Mesh(r,s);return o}(0,h,i,n);break;case"NurbsCurve":u=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)}(h,i);break;case"LimbNode":case"Null":default:u=new THREE.Group}u.name=THREE.PropertyBinding.sanitizeNodeName(l.attrName),u.ID=c}!function(e,t,i){if("RotationOrder"in i){var n=["XYZ","XZY","YZX","ZXY","YXZ","ZYX","SphericXYZ"],o=parseInt(i.RotationOrder.value,10);o>0&&o<6?console.warn("THREE.FBXLoader: unsupported Euler Order: %s. Currently only XYZ order is supported. Animations and rotations may be incorrect.",n[o]):6===o&&console.warn("THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect.")}"Lcl_Translation"in i&&t.position.fromArray(i.Lcl_Translation.value);if("Lcl_Rotation"in i){var r=i.Lcl_Rotation.value.map(THREE.Math.degToRad);r.push("ZYX"),t.rotation.fromArray(r)}"Lcl_Scaling"in i&&t.scale.fromArray(i.Lcl_Scaling.value);if("PreRotation"in i){var s=i.PreRotation.value.map(THREE.Math.degToRad);s[3]="ZYX";var a=(new THREE.Euler).fromArray(s);a=(new THREE.Quaternion).setFromEuler(a);var c=(new THREE.Quaternion).setFromEuler(t.rotation);a.multiply(c),t.rotation.setFromQuaternion(a,"ZYX")}}(0,u,l),r.set(c,u)}return r}(e,i,n,o,t),a=e.Objects.Model;return s.forEach(function(i){var n=a[i.ID];!function(e,t,i,n,o){if("LookAtProperty"in i){n.get(t.ID).children.forEach(function(i){if("LookAtProperty"===i.relationship){var n=e.Objects.Model[i.ID];if("Lcl_Translation"in n){var r=n.Lcl_Translation.value;void 0!==t.target?(t.target.position.fromArray(r),o.add(t.target)):t.lookAt((new THREE.Vector3).fromArray(r))}}})}}(e,i,n,t,r);t.get(i.ID).parents.forEach(function(e){var t=s.get(e.ID);void 0!==t&&t.add(i)}),null===i.parent&&r.add(i)}),function(e,t,i,n,o){var r=function(e){var t={};if("Pose"in e.Objects){var i=e.Objects.Pose;for(var n in i)if("BindPose"===i[n].attrType){var o=i[n].PoseNode;Array.isArray(o)?o.forEach(function(e){t[e.Node]=(new THREE.Matrix4).fromArray(e.Matrix.a)}):t[o.Node]=(new THREE.Matrix4).fromArray(o.Matrix.a)}}return t}(e);for(var s in t){var a=t[s];o.get(parseInt(a.ID)).parents.forEach(function(e){if(i.has(e.ID)){var t=e.ID;o.get(t).parents.forEach(function(e){if(n.has(e.ID)){n.get(e.ID).bind(new THREE.Skeleton(a.bones),r[e.ID])}})}})}}(e,i,n,s,t),function(e,t,i){i.animations=[];var n=function(e,t){if(void 0===e.Objects.AnimationCurve)return;var i=function(e){var t=e.Objects.AnimationCurveNode,i=new Map;for(var n in t){var o=t[n];if(null!==o.attrName.match(/S|R|T/)){var r={id:o.id,attr:o.attrName,curves:{}};i.set(r.id,r)}}return i}(e);!function(e,t,i){var n=e.Objects.AnimationCurve;for(var o in n){var r={id:n[o].id,times:n[o].KeyTime.a.map(g),values:n[o].KeyValueFloat.a},s=t.get(r.id);if(void 0!==s){var a=s.parents[0].ID,c=s.parents[0].relationship,l="";if(c.match(/X/))l="x";else if(c.match(/Y/))l="y";else{if(!c.match(/Z/))continue;l="z"}i.get(a).curves[l]=r}}}(e,t,i);var n=function(e,t,i){var n=e.Objects.AnimationLayer,o=new Map;for(var r in n){var s=[],a=t.get(parseInt(r));if(void 0!==a){a.children.forEach(function(n,o){if(i.has(n.ID)){var r=i.get(n.ID);if(void 0!==r.curves.x||void 0!==r.curves.y||void 0!==r.curves.z){if(void 0===s[o]){var a;t.get(n.ID).parents.forEach(function(e){void 0!==e.relationship&&(a=e.ID)});var c=e.Objects.Model[a.toString()],l={modelName:THREE.PropertyBinding.sanitizeNodeName(c.attrName),initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};"Lcl_Translation"in c&&(l.initialPosition=c.Lcl_Translation.value),"Lcl_Rotation"in c&&(l.initialRotation=c.Lcl_Rotation.value),"Lcl_Scaling"in c&&(l.initialScale=c.Lcl_Scaling.value),"PreRotation"in c&&(l.preRotations=c.PreRotation.value),s[o]=l}s[o][r.attr]=r}}}),o.set(parseInt(r),s)}}return o}(e,t,i);return function(e,t,i){var n=e.Objects.AnimationStack,o={};for(var r in n){var s=t.get(parseInt(r)).children;s.length>1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");var a=i.get(s[0].ID);o[r]={name:n[r].attrName,layer:a}}return o}(e,t,n)}(e,t);if(void 0===n)return;for(var o in n){var r=function(e){var t=[];return e.layer.forEach(function(e){t=t.concat(function(e){var t=[];if(void 0!==e.T&&Object.keys(e.T.curves).length>0){var i=h(e.modelName,e.T.curves,e.initialPosition,"position");void 0!==i&&t.push(i)}if(void 0!==e.R&&Object.keys(e.R.curves).length>0){var n=function(e,t,i,n){void 0!==t.x&&(t.x.values=t.x.values.map(THREE.Math.degToRad)),void 0!==t.y&&(t.y.values=t.y.values.map(THREE.Math.degToRad)),void 0!==t.z&&(t.z.values=t.z.values.map(THREE.Math.degToRad));var o=d(t),r=u(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));for(var s=new THREE.Quaternion,a=new THREE.Euler,c=[],l=0;l0){var o=h(e.modelName,e.S.curves,e.initialScale,"scale");void 0!==o&&t.push(o)}return t}(e))}),new THREE.AnimationClip(e.name,-1,t)}(n[o]);i.animations.push(r)}}(e,t,r),function(e,t){if("GlobalSettings"in e&&"AmbientColor"in e.GlobalSettings){var i=e.GlobalSettings.AmbientColor.value,n=i[0],o=i[1],r=i[2];if(0!==n||0!==o||0!==r){var s=new THREE.Color(n,o,r);t.add(new THREE.AmbientLight(s,1))}}}(e,r),r}function h(e,t,i,n){var o=d(t),r=u(o,t,i);return new THREE.VectorKeyframeTrack(e+"."+n,o,r)}function u(e,t,i){var n=i,o=[],r=-1,s=-1,a=-1;return e.forEach(function(e){if(t.x&&(r=t.x.times.indexOf(e)),t.y&&(s=t.y.times.indexOf(e)),t.z&&(a=t.z.times.indexOf(e)),-1!==r){var i=t.x.values[r];o.push(i),n[0]=i}else o.push(n[0]);if(-1!==s){var c=t.y.values[s];o.push(c),n[1]=c}else o.push(n[1]);if(-1!==a){var l=t.z.values[a];o.push(l),n[2]=l}else o.push(n[2])}),o}function d(e){var t=[];return void 0!==e.x&&(t=t.concat(e.x.times)),void 0!==e.y&&(t=t.concat(e.y.times)),void 0!==e.z&&(t=t.concat(e.z.times)),t=t.sort(function(e,t){return e-t}).filter(function(e,t,i){return i.indexOf(e)==t})}function p(){}function f(){}function v(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=void 0===t||t}function m(){}function y(e){var t=e.match(/FBXVersion: (\d+)/);if(t){return parseInt(t[1])}throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function g(e){return e/46186158e3}function E(e){return e.split(",").map(function(e){return parseFloat(e)})}function b(e,t,i){return void 0===t&&(t=0),void 0===i&&(i=e.byteLength),THREE.LoaderUtils.decodeText(new Uint8Array(e,t,i))}function w(e,t,i,n){for(var o=i,r=0;o=t.length&&t===b(e,0,t.length)}(t))r=(new f).parse(t);else{var c=b(t);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,o=0;o1&&(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(),o=t[2].replace(/^"/,"").replace(/"$/,"").trim();"Content"===n&&","===o&&(o=i.replace(/"/g,"").replace(/,$/,"").trim());var r=this.getCurrentNode();if("Properties70"!==r.name){if("C"===n){var s=o.split(",").slice(1),a=parseInt(s[0]),c=parseInt(s[1]),l=o.split(",").slice(3);n="connections",function(e,t){for(var i=0,n=e.length,o=t.length;i=e.size():e.getOffset()+160+16>=e.size()},parseNode:function(e,t){var i={},n=t>=7500?e.getUint64():e.getUint32(),o=t>=7500?e.getUint64():e.getUint32(),r=(t>=7500?e.getUint64():e.getUint32(),e.getUint8()),s=e.getString(r);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===o&&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 o=[];i.propertyList.forEach(function(e,t){0!==t&&o.push(e)}),void 0===t.connections&&(t.connections=[]),t.connections.push(o)}else if("Properties70"===i.name){Object.keys(i).forEach(function(e){t[e]=i[e]})}else if("Properties70"===e&&"P"===i.name){var r,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_")),r="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:r}}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(),o=e.getUint32(),r=e.getUint32();if(0===o)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)}void 0===window.Zlib&&console.error("THREE.FBXLoader: External library Inflate.min.js required, obtain or import from https://github.com/imaya/zlib.js");var s=new v(new Zlib.Inflate(new Uint8Array(e.getArrayBuffer(r))).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)}}}),Object.assign(v.prototype,{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(t)}}),Object.assign(m.prototype,{add:function(e,t){this[e]=t}})}()},{}],4:[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})},{}],5:[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}},{}],6:[function(e,t,i){"use strict";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,i,n){var o=this,r=new THREE.XHRLoader(this.manager);r.setResponseType("arraybuffer"),r.load(e,function(e){t(o.parse(e))},i,n)},setPropertyNameMapping:function(e){this.propertyNameMapping=e},bin2str:function(e){for(var t=new Uint8Array(e),i="",n=0;n=n.elements[s].count&&(s++,a=0);var h=this.parseASCIIElement(n.elements[s].properties,l);this.handleElement(i,n.elements[s].name,h),a++}}return this.postProcess(i)},postProcess:function(e){if(e.useColor){for(var 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*r.SQRT3*this._cellWidth,this._hashDelimeter=".",this._directions=[new r.Cell(1,-1,0),new r.Cell(1,0,-1),new r.Cell(0,1,-1),new r.Cell(-1,1,0),new r.Cell(-1,0,1),new r.Cell(0,-1,1)],this._diagonals=[new r.Cell(2,-1,-1),new r.Cell(1,1,-2),new r.Cell(-1,2,-1),new r.Cell(-2,1,1),new r.Cell(-1,-1,2),new r.Cell(1,-2,1)],this._list=[],this._vec3=new THREE.Vector3,this._cel=new r.Cell,this._conversionVec=new THREE.Vector3,this._geoCache=[],this._matCache=[]},r.HexGrid.TWO_THIRDS=2/3,r.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*(r.HexGrid.TWO_THIRDS/this.cellSize),i=(-e.x/3+r.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*(r.HexGrid.TWO_THIRDS/this.cellSize),i=(-e.x/3+r.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,o,r=this._directions.length;for(this._list.length=0,n=0;r>n;n++)this._cel.copy(e),this._cel.add(this._directions[n]),!(o=this.cells[this.cellToHash(this._cel)])||i&&!i(e,o)||this._list.push(o);if(t)for(n=0;r>n;n++)this._cel.copy(e),this._cel.add(this._diagonals[n]),!(o=this.cells[this.cellToHash(this._cel)])||i&&!i(e,o)||this._list.push(o);return this._list},getRandomCell:function(){var e,t=0,i=r.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 o=this._geoCache[n];o||(this.extrudeSettings.amount=n,o=new THREE.ExtrudeGeometry(this.cellShape,this.extrudeSettings),this._geoCache[n]=o);var s=new r.Tile({size:this.cellSize,scale:t,cell:e,geometry:o,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=r.Tools.merge(i,e),this.cellSize=i.cellSize,this._cellWidth=2*this.cellSize,this._cellLength=.5*r.SQRT3*this._cellWidth,this.autogenerated=!0,this.extrudeSettings=i.extrudeSettings;var n,o,s;for(n in this.cells)s=this.cells[n],(o=this.generateTile(s,i.tileScale,i.material)).position.copy(this.cellToPixel(s)),o.position.y=0,t.push(o);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,r.PI/2),t},generate:function(e){e=e||{},this.size=void 0===e.size?this.size:e.size;var t,i,n,o;for(t=-this.size;tn;n++)for(o=-e;e+1>o;o++)if(s=-n-o,Math.abs(n)<=e&&Math.abs(o)<=e&&Math.abs(s)<=e){this._cel.set(n,o,s);var c=new THREE.Line(a,i);c.position.copy(this.cellToPixel(this._cel)),c.rotation.x=90*r.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;r.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*r.SQRT3*this._cellWidth,this.extrudeSettings=e.extrudeSettings,this.autogenerated=e.autogenerated,t=0;tr&&o>s?t=-i-n:r>s?i=-t-n:n=-t-i,this._cel.set(t,i,n)}},r.HexGrid.prototype.constructor=r.HexGrid,r.SqrGrid=function(e){e=e||{},this.type=r.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 r.Cell(1,0,0),new r.Cell(0,-1,0),new r.Cell(-1,0,0),new r.Cell(0,1,0)],this._diagonals=[new r.Cell(-1,-1,0),new r.Cell(-1,1,0),new r.Cell(1,1,0),new r.Cell(1,-1,0)],this._list=[],this._vec3=new THREE.Vector3,this._cel=new r.Cell,this._conversionVec=new THREE.Vector3,this._geoCache=[],this._matCache=[]},r.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,o,r=this._directions.length;for(this._list.length=0,n=0;r>n;n++)this._cel.copy(e),this._cel.add(this._directions[n]),!(o=this.cells[this.cellToHash(this._cel)])||i&&!i(e,o)||this._list.push(o);if(t)for(n=0;r>n;n++)this._cel.copy(e),this._cel.add(this._diagonals[n]),!(o=this.cells[this.cellToHash(this._cel)])||i&&!i(e,o)||this._list.push(o);return this._list},getRandomCell:function(){var e,t=0,i=r.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 o=this._geoCache[n];o||(this.extrudeSettings.amount=n,o=new THREE.ExtrudeGeometry(this.cellShape,this.extrudeSettings),this._geoCache[n]=o);var s=new r.Tile({size:this.cellSize,scale:t,cell:e,geometry:o,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=r.Tools.merge(i,e),this.cellSize=i.cellSize,this._fullCellSize=2*this.cellSize,this.autogenerated=!0,this.extrudeSettings=i.extrudeSettings;var n,o,s;for(n in this.cells)s=this.cells[n],(o=this.generateTile(s,i.tileScale,i.material)).position.copy(this.cellToPixel(s)),o.position.y=0,t.push(o);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,r.PI/2),t},generate:function(e){e=e||{},this.size=void 0===e.size?this.size:e.size;var t,i,n,o=Math.ceil(this.size/2);for(t=-o;o>t;t++)for(i=-o;o>i;i++)n=new r.Cell(t,i+1),this.add(n)},generateOverlay:function(e,t,i){var n,o,s=Math.ceil(e/2);for(n=-s;s>n;n++)for(o=-s;s>o;o++){this._cel.set(n,o);var a=new THREE.Line(this.cellGeo,i);a.position.copy(this.cellToPixel(this._cel)),a.rotation.x=90*r.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){r.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,r.LinkedList=e}(),function(){var e=function(e,t,i,n,o){this._listener=t,this.isOnce=i,this.context=n,this.signal=e,this._priority=o||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,o){var r,s=this._indexOfListener(t,n);if(-1!==s){if((r=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 r=new e(this,t,i,n,o),this._addBinding(r);return this.memorize&&this._prevParams&&r.execute(this._prevParams),r},_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,r.Signal=t}(),r.AStarFinder=function(e){e=e||{};var t={allowDiagonal:!1,heuristicFilter:null};t=r.Tools.merge(t,e),this.allowDiagonal=t.allowDiagonal,this.heuristicFilter=t.heuristicFilter,this.list=new r.LinkedList},r.AStarFinder.prototype={findPath:function(e,t,i,n){var o,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),o=this.list.shift(),o._visited=!0,o===t)return r.PathUtil.backtrace(t);for(l=0,h=(a=n.getNeighbors(o,this.allowDiagonal,i)).length;h>l;l++)if((c=a[l]).walkable&&(s=o._calcCost+n.distance(o,c),!c._visited||se?1:-1,r=n>t?1:-1,c=s-a;e!==i||t!==n;)u.push([e,t]),(l=2*c)>-a&&(c-=a,e+=o),s>l&&(c+=s,t+=r);return u},expandPath:function(e){var t,i,n,o,r,s,a=[],c=e.length;if(2>c)return a;for(r=0;c-1>r;++r)for(t=e[r],i=e[r+1],o=(n=this.interpolate(t[0],t[1],i[0],i[1])).length,s=0;o-1>s;++s)a.push(n[s]);return a.push(e[c-1]),a},smoothenPath:function(e,t){var i,n,o,r,s,a,c,l,h,u,d,p,f=t.length,v=t[0][0],m=t[0][1],y=t[f-1][0],g=t[f-1][1];for(s=[[i=v,n=m]],c=2;f>c;++c){for(o=(h=t[c])[0],r=h[1],u=this.interpolate(i,n,o,r),p=!1,l=1;l0?(e=i[0],t=e.object.userData.structure,this.pickedObject!=t&&(this.pickedObject&&this.signal.dispatch(r.MouseCaster.OUT,this.pickedObject),this.pickedObject=t,this.selectedObject=null,this.signal.dispatch(r.MouseCaster.OVER,this.pickedObject)),this.position.copy(e.point),this.screenPosition.z=e.distance):(this.pickedObject&&this.signal.dispatch(r.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(r.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(r.MouseCaster.UP,this.pickedObject),this.selectedObject&&this.pickedObject&&this.selectedObject.uniqueID===this.pickedObject.uniqueID&&this.signal.dispatch(r.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(r.MouseCaster.WHEEL,this.wheel)}}},r.MouseCaster.prototype.constructor=r.MouseCaster,r.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=r.Tools.merge(i,e),"boolean"!=typeof t&&(n=r.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 o=window.innerWidth/this.orthoZoom,s=window.innerHeight/this.orthoZoom;this.camera=new THREE.OrthographicCamera(o/-2,o/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)},r.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)}},r.Scene.prototype.constructor=r.Scene,r.SelectionManager=function(e){this.mouse=e,this.onSelect=new r.Signal,this.onDeselect=new r.Signal,this.selected=null,this.toggleSelection=!1,this.mouse.signal.add(this.onMouse,this)},r.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 r.MouseCaster.DOWN:t||this.clearSelection();break;case r.MouseCaster.CLICK:this.select(t)}}},r.SelectionManager.prototype.constructor=r.SelectionManager,r.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":o(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),o=n&&[]||{};return n?(e=e||[],o=o.concat(e),t.forEach(function(t,n){void 0===o[n]?o[n]=t:i.isPlainObject(t)?o[n]=i.merge(e[n],t):-1===e.indexOf(t)&&o.push(t)}),o):(e&&i.isPlainObject(e)&&Object.keys(e).forEach(function(t){o[t]=e[t]}),Object.keys(t).forEach(function(n){t[n]&&i.isPlainObject(t[n])&&e[n]?o[n]=i.merge(e[n],t[n]):o[n]=t[n]}),o)},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 o=t,r=i,s=1<o;)if(e[o]&s){--r;var a=e[o];e[o]=e[r],e[r]=a}else++o;this.radixSort(e,t,r,n-1),this.radixSort(e,r,i,n-1)}},randomizeRGB:function(e,t){var i,n,o=e.split(","),r="rgb(";for(t=this.randomInt(t),i=0;3>i;i++)0>(n=parseInt(o[i])+t)?n=0:n>255&&(n=255),r+=n+",";return r=r.substring(0,r.length-1),r+=")"},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(g||"keyLocation"in e){var i=g?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=v[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 o="KeyboardEvent"in e;o||(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 r=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:r}}),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 v={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(v,"mac",{OSLeft:{key:"Meta"},OSRight:{key:"Meta"}});var m={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"},y=function(e,t){var i={};return Object.keys(e).forEach(function(n){var o=e[n];t in o&&(i[o[t]]=o)}),i}(d,"code");try{var g=o&&"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 m.hasOwnProperty(e)?m[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:r}}),e(KeyboardEvent.prototype,"locale",{get:function(){return""}})}(),"queryKeyCap"in e.KeyboardEvent||(e.KeyboardEvent.queryKeyCap=function(e,t){if(e=String(e),!y.hasOwnProperty(e))return"Undefined";if(t&&"en-us"!==String(t).toLowerCase())throw Error("Unsupported locale");var i=y[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:r,e.locale=""}}}(window)},{}],11:[function(e,t,i){"use strict";t.exports=AFRAME.registerComponent("checkpoint-controls",{schema:{enabled:{default:!0},mode:{default:"teleport",oneOf:["teleport","animate"]},animateSpeed:{default:3}},init:function(){this.active=!0,this.checkpoint=null,this.isNavMeshConstrained=!1,this.offset=new THREE.Vector3,this.position=new THREE.Vector3,this.targetPosition=new THREE.Vector3},play:function(){this.active=!0},pause:function(){this.active=!1},setCheckpoint:function(e){var t=this.el;this.active&&this.checkpoint!==e&&(this.checkpoint&&t.emit("navigation-end",{checkpoint:this.checkpoint}),this.checkpoint=e,this.sync(),this.position.distanceTo(this.targetPosition)<.1?this.checkpoint=null:(t.emit("navigation-start",{checkpoint:e}),"teleport"===this.data.mode&&(this.el.setAttribute("position",this.targetPosition),this.checkpoint=null,t.emit("navigation-end",{checkpoint:e}),t.components["movement-controls"].updateNavLocation())))},isVelocityActive:function(){return!(!this.active||!this.checkpoint)},getVelocity:function(){if(this.active){var e=this.data,t=this.offset,i=this.position,n=this.targetPosition,o=this.checkpoint;return this.sync(),i.distanceTo(n)<.1?(this.checkpoint=null,this.el.emit("navigation-end",{checkpoint:o}),t.set(0,0,0)):(t.setLength(e.animateSpeed),t)}},sync:function(){var e=this.offset,t=this.position,i=this.targetPosition;t.copy(this.el.getAttribute("position")),i.copy(this.checkpoint.object3D.getWorldPosition()),i.add(this.checkpoint.components.checkpoint.getOffset()),e.copy(i).sub(t)}})},{}],12:[function(e,t,i){"use strict";var n=e("../../lib/GamepadButton"),o=e("../../lib/GamepadButtonEvent");t.exports=AFRAME.registerComponent("gamepad-controls",{GamepadButton:n,schema:{controller:{default:0,oneOf:[0,1,2,3]},enabled:{default:!0},debug:{default:!1},camera:{default:"[camera]",type:"selector"},rotationSensitivity:{default:2}},init:function(){var e=this.el.sceneEl;this.prevTime=window.performance.now(),this.buttons={};var t=this.el.object3D.rotation;this.pitch=new THREE.Object3D,this.pitch.rotation.x=THREE.Math.degToRad(t.x),this.yaw=new THREE.Object3D,this.yaw.position.y=10,this.yaw.rotation.y=THREE.Math.degToRad(t.y),this.yaw.add(this.pitch),e.addBehavior(this)},update:function(){this.tick()},tick:function(e,t){this.updateButtonState(),this.updateRotation(t)},remove:function(){},isVelocityActive:function(){if(!this.data.enabled||!this.isConnected())return!1;var e=this.getDpad(),t=this.getJoystick(0),i=e.x||t.x,n=e.y||t.y;return Math.abs(i)>.2||Math.abs(n)>.2},getVelocityDelta:function(){var e=this.getDpad(),t=this.getJoystick(0),i=e.x||t.x,n=e.y||t.y,o=new THREE.Vector3;return Math.abs(i)>.2&&(o.x+=i),Math.abs(n)>.2&&(o.z+=n),o},isRotationActive:function(){if(!this.data.enabled||!this.isConnected())return!1;var e=this.getJoystick(1);return 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,o=t.camera.components["look-controls"],r=o&&o.pitchObject&&o.yawObject;r&&(n.rotation.copy(o.pitchObject.rotation),i.rotation.copy(o.yawObject.rotation));var s=this.getJoystick(1);Math.abs(s.x)<=.2&&(s.x=0),Math.abs(s.y)<=.2&&(s.y=0),s.multiplyScalar(t.rotationSensitivity*e/1e3),i.rotation.y-=s.x,n.rotation.x-=s.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),r&&(o.pitchObject.rotation.copy(n.rotation),o.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(o),s.constrainToNavMesh&&!1!==a.isNavMeshConstrained){if(c.lengthSq()<1e-5)return;e.copy(r.object3D.position),t.copy(c).multiplyScalar(o/1e3).add(e);var l=r.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),r.object3D.position.copy(i)}else r.hasAttribute("velocity")?r.setAttribute("velocity",c):(r.object3D.position.x+=c.x*o/1e3,r.object3D.position.y+=c.y*o/1e3,r.object3D.position.z+=c.z*o/1e3)}}}}(),updateVelocityCtrl:function(){var e=this.data;if(e.enabled){for(var t=0,i=e.controls.length;t0&&(this.zVel=-1)}})},{}],18:[function(e,t,i){"use strict";function n(e){return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&")}var o={once:THREE.LoopOnce,repeat:THREE.LoopRepeat,pingpong:THREE.LoopPingPong};t.exports=AFRAME.registerComponent("animation-mixer",{schema:{clip:{default:"*"},duration:{default:0},crossFadeDuration:{default:0},loop:{default:"repeat",oneOf:Object.keys(o)},repetitions:{default:1/0,min:0}},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){e&&(this.stopAction(),this.data.clip&&this.playAction())},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},userHeight:{default:1.6},linearDamping:{default:.05},enableSlopes:{default:!0}},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.getAttribute("position"));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-t.height,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.body;n.velocity.copy(i.getAttribute("velocity")),n.position.copy(i.getAttribute("position")),n.position.y+=this.data.userHeight}},step:function(){var e=new THREE.Vector3,t=new THREE.Vector3,i=new THREE.Vector3,n=new THREE.Vector3;return function(o,r){if(r){var s=this.body,a=this.data,c=void 0,l=-1/0,h=void 0,u=this.system.getContacts();r=Math.min(r,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=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)}if(t.copy(e).normalize(),h&&t.y<.5?(a.enableSlopes?n.y<1-1e-6&&n.copy(this.raycastToGround(h,n)):n.set(0,1,0),e=e.projectOnPlane(n)):this.system.driver.world&&e.add(this.system.driver.world.gravity.scale(4*r/1e3)),h&&h.el&&h.el.components.velocity){var f=h.el.getAttribute("velocity");s.position.copy({x:s.position.x+f.x*r/1e3,y:s.position.y+f.y*r/1e3,z:s.position.z+f.z*r/1e3})}s.velocity.copy(e),s.position.y-=a.userHeight,this.el.setAttribute("velocity",s.velocity),this.el.setAttribute("position",s.position)}}}(),raycastToGround:function(e,t){var i=void 0,n=void 0,o=this.body.position,r=this.body.position.clone();return r.y-=this.data.height,(i=new CANNON.Ray(o,r))._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 Map;return function(){var o=this.el,r=this.data,s=[],a=void 0;o.getObject3D("mesh")&&(n.clear(),e.copy(o.object3D.getWorldPosition()),o.object3D.getWorldScale(i),a=r.radius*function(e){return Math.max.apply(null,e.toArray())}(i),this.els.forEach(function(i){var o=void 0,r=void 0,c=void 0,l=void 0,h=void 0,u=void 0;i.isEntity&&(r=i.getObject3D("mesh"))&&(u=(l=(new THREE.Box3).setFromObject(r)).getSize(),h=Math.max(u.x,u.y,u.z)/2,o=Math.sqrt(2*h*h),l.getCenter(t),o&&(c=e.distanceTo(t))n.get(t)?1:-1}).forEach(this.handleHit),0===s.length&&o.emit("hit",{el:null}),this.collisions.filter(function(e){return!n.has(e)}).forEach(this.handleHitEnd),this.collisions=s)}}(),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,o){var r=this.el,s=this.data,a=this.raycaster,c=s.speed*o/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)||[],r.emit("nav-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 r.emit("nav-end");var h=r.object3D.position,u=this.path[0];t.subVectors(u,h);var d=void 0;if(t.length()0;){var o=n.pop();if(o===i){for(var r=o,s=[];r.parent;)s.push(r),r=r.parent;return this.cleanUp(s),s.reverse()}o.closed=!0;for(var a=this.neighbours(e,o),c=0,l=a.length;c0&&(this.content[0]=t,this.bubbleUp(0)),e}},{key:"remove",value: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)1e4)){o.array_intersect(e.vertexIds,t.polygons[i].vertexIds).length>=2&&e.neighbours.push(t.polygons[i])}}},{key:"_buildPolygonsFromGeometry",value:function(e){var t=this,i=[],n=e.vertices,o=e.faceVertexUvs;e.faces.forEach(function(e){i.push({id:r++,vertexIds:[e.a,e.b,e.c],centroid:e.centroid,normal:e.normal,neighbours:[]})});var s={polygons:i,vertices:n,faceVertexUvs:o};return i.forEach(function(e){t._buildPolygonNeighbours(e,s)}),s}},{key:"_getSharedVerticesInOrder",value:function(e,t){var i=e.vertexIds,n=t.vertexIds,o=[];return i.forEach(function(e){n.includes(e)&&o.push(e)}),o.length<2?[]:(o.includes(i[0])&&o.includes(i[i.length-1])&&i.push(i.shift()),o.includes(n[0])&&o.includes(n[n.length-1])&&n.push(n.shift()),o.length=0,i.forEach(function(e){n.includes(e)&&o.push(e)}),o)}}]),e}();t.exports=s},{"./utils":48}],46:[function(e,t,i){"use strict";var n=function(){function e(e,t){for(var i=0;i0)){t.push(n),n=i=n,r=i,a=s=a,c=s,l=s;continue}r=u,c=l}if(o.triarea2(i,n,h)>=0){if(!(o.vequal(i,n)||o.triarea2(i,r,h)<0)){t.push(r),n=i=r,r=i,a=s=c,c=s,l=s;continue}n=h,a=l}}return 0!==t.length&&o.vequal(t[t.length-1],e[e.length-1].left)||t.push(e[e.length-1].left),this.path=t,t}}]),e}();t.exports=r},{"./utils":48}],47:[function(e,t,i){"use strict";var n=function(){function e(e,t){for(var i=0;i3&&void 0!==arguments[3]&&arguments[3],r=this.zones[t].groups[i],s=this.zones[t].vertices,a=null,c=1/0;return r.forEach(function(t){var i=o.distanceToSquared(t.centroid,e);i2))for(var g=0;g=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],o=i[0],r=e.slice();r[0]!==n;)r.push(r.shift());for(var s=0,a=t.slice();a[0]!==o;)if(a.push(a.shift()),s++>10)throw new Error("Unexpected state");return a.shift(),a.pop(),r=r.concat(a)}},{key:"setPolygonCentroid",value: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)}},{key:"cleanPolygon",value:function(e,t){for(var i=[],n=t.vertices,o=0;oMath.PI-.01&&d0?o.forEach(function(e){e<0&&(n=!1)}):o.forEach(function(e){e>0&&(n=!1)}),n}},{key:"distanceToSquared",value:function(e,t){var i=e.x-t.x,n=e.y-t.y,o=e.z-t.z;return i*i+n*n+o*o}},{key:"isPointInPoly",value:function(e,t){for(var i=!1,n=-1,o=e.length,r=o-1;++nn-.5&&this.isPointInPoly(r,e))}},{key:"triarea2",value:function(e,t,i){var n=t.x-e.x,o=t.z-e.z;return(i.x-e.x)*o-n*(i.z-e.z)}},{key:"vequal",value:function(e,t){return this.distanceToSquared(e,t)<1e-5}},{key:"array_intersect",value:function(){var e=void 0,t=void 0,i=void 0,n=void 0,o=void 0,r=[],s={},a=void 0;for(a=arguments.length-1,i=arguments[0].length,t=0,e=0;e<=a;e++)(n=arguments[e].length)