1 |
- !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;s<n.length;s++)o(n[s]);return o}({1:[function(e,t,i){"use strict";e("./")},{"./":2}],2:[function(e,t,i){"use strict";e("./src/controls"),e("./src/loaders"),e("./src/misc"),e("./src/pathfinding"),e("./src/primitives")},{"./src/controls":14,"./src/loaders":22,"./src/misc":29,"./src/pathfinding":35,"./src/primitives":43}],3:[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},o="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)};THREE.LoaderUtils={extractUrlBase:THREE.Loader.prototype.extractUrlBase,decodeText:function(e){return(new TextDecoder).decode(e)}},function(){function e(e){var t={},i={};if("Video"in e.Objects){var n=e.Objects.Video;for(var o in n){var r=n[o];if(t[l=parseInt(o)]=r.Filename,"Content"in r){var s=r.Content instanceof ArrayBuffer&&r.Content.byteLength>0,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;r<n.length;++r)o.push(r);return{dataSize:1,buffer:n,indices:o,mappingType:t,referenceType:i}}(i.LayerElementMaterial[0]);if(i.LayerElementNormal)var y=function(e){var t=e.MappingInformationType,i=e.ReferenceInformationType,n=e.Normals.a,o=[];"IndexToDirect"===i&&("NormalIndex"in e?o=e.NormalIndex.a:"NormalsIndex"in e&&(o=e.NormalsIndex.a));return{dataSize:3,buffer:n,indices:o,mappingType:t,referenceType:i}}(i.LayerElementNormal[0]);if(i.LayerElementUV)for(var g=[],E=0;i.LayerElementUV[E];)g.push(function(e){var t=e.MappingInformationType,i=e.ReferenceInformationType,n=e.UV.a,o=[];"IndexToDirect"===i&&(o=e.UVIndex.a);return{dataSize:2,buffer:n,indices:o,mappingType:t,referenceType:i}}(i.LayerElementUV[E])),E++;var b={};null!==n&&n.rawBones.forEach(function(e,t){e.indices.forEach(function(i,n){void 0===b[i]&&(b[i]=[]),b[i].push({id:t,weight:e.weights[n]})})});var w=0,T=0,x=!1,S=[],C=[],R=[],k=[],M=[],A=[];s.forEach(function(e,t){var i=!1;e<0&&(e^=-1,s[t]=e,i=!0);var o=[],E=[];if(S.push(3*e,3*e+1,3*e+2),v){O=c(t,w,e,v);R.push(O[0],O[1],O[2])}if(n){if(void 0!==b[e]&&b[e].forEach(function(e){E.push(e.weight),o.push(e.id)}),E.length>4){x||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),x=!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===k[n]&&(k[n]=[]),k[n].push(o[0]),k[n].push(o[1])}),T++,i){for(var H=2;H<T;H++)a.push(r[S[0]]),a.push(r[S[1]]),a.push(r[S[2]]),a.push(r[S[3*(H-1)]]),a.push(r[S[3*(H-1)+1]]),a.push(r[S[3*(H-1)+2]]),a.push(r[S[3*H]]),a.push(r[S[3*H+1]]),a.push(r[S[3*H+2]]),n&&(p.push(M[0]),p.push(M[1]),p.push(M[2]),p.push(M[3]),p.push(M[4*(H-1)]),p.push(M[4*(H-1)+1]),p.push(M[4*(H-1)+2]),p.push(M[4*(H-1)+3]),p.push(M[4*H]),p.push(M[4*H+1]),p.push(M[4*H+2]),p.push(M[4*H+3]),f.push(A[0]),f.push(A[1]),f.push(A[2]),f.push(A[3]),f.push(A[4*(H-1)]),f.push(A[4*(H-1)+1]),f.push(A[4*(H-1)+2]),f.push(A[4*(H-1)+3]),f.push(A[4*H]),f.push(A[4*H+1]),f.push(A[4*H+2]),f.push(A[4*H+3])),v&&(h.push(R[0]),h.push(R[1]),h.push(R[2]),h.push(R[3*(H-1)]),h.push(R[3*(H-1)+1]),h.push(R[3*(H-1)+2]),h.push(R[3*H]),h.push(R[3*H+1]),h.push(R[3*H+2])),m&&"AllSame"!==m.mappingType&&(d.push(_),d.push(_),d.push(_)),y&&(l.push(C[0]),l.push(C[1]),l.push(C[2]),l.push(C[3*(H-1)]),l.push(C[3*(H-1)+1]),l.push(C[3*(H-1)+2]),l.push(C[3*H]),l.push(C[3*H+1]),l.push(C[3*H+2])),g&&g.forEach(function(e,t){void 0===u[t]&&(u[t]=[]),u[t].push(k[t][0]),u[t].push(k[t][1]),u[t].push(k[t][2*(H-1)]),u[t].push(k[t][2*(H-1)+1]),u[t].push(k[t][2*H]),u[t].push(k[t][2*H+1])});w++,T=0,S=[],C=[],R=[],k=[],M=[],A=[]}});var D=new THREE.BufferGeometry;D.name=i.name;var L=new THREE.Float32BufferAttribute(a,3);o.applyToBufferAttribute(L),D.addAttribute("position",L),h.length>0&&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;s<a;s+=4)o.push((new THREE.Vector4).fromArray(r,s));var c,l;if("Closed"===e.Form)o.push(o[0]);else if("Periodic"===e.Form){c=i,l=n.length-1-c;for(s=0;s<i;++s)o.push(o[s])}var h=new THREE.NURBSCurve(i,n,o,c,l).getPoints(7*o.length),u=new Float32Array(3*h.length);h.forEach(function(e,t){e.toArray(u,3*t)});var d=new THREE.BufferGeometry;return d.addAttribute("position",new THREE.BufferAttribute(u,3)),d}(i)}}(e,t.get(parseInt(r)),o[r],i);n.set(parseInt(r),s)}}return n}function c(e,t,i,n){return x[n.mappingType][n.referenceType](e,t,i,n)}function l(e,t,i,n,o){var r=new THREE.Group,s=function(e,t,i,n,o){var r=new Map,s=e.Objects.Model;for(var a in s){var c=parseInt(a),l=s[a],h=o.get(c),u=function(e,t,i,n){var o=null;return e.parents.forEach(function(e){for(var r in t){var s=t[r];s.rawBones.forEach(function(t,r){if(t.ID===e.ID){var a=o;(o=new THREE.Bone).matrixWorld.copy(t.transformLink),o.name=THREE.PropertyBinding.sanitizeNodeName(n),o.ID=i,s.bones[r]=o,null!==a&&o.add(a)}})}}),o}(h,t,c,l.attrName);if(!u){switch(l.attrType){case"Camera":u=function(e,t){var i,n;if(t.children.forEach(function(t){var i=e.Objects.NodeAttribute[t.ID];void 0!==i&&(n=i)}),void 0===n)i=new THREE.Object3D;else{var o=0;void 0!==n.CameraProjectionType&&1===n.CameraProjectionType.value&&(o=1);var r=1;void 0!==n.NearPlane&&(r=n.NearPlane.value/1e3);var s=1e3;void 0!==n.FarPlane&&(s=n.FarPlane.value/1e3);var a=window.innerWidth,c=window.innerHeight;void 0!==n.AspectWidth&&void 0!==n.AspectHeight&&(a=n.AspectWidth.value,c=n.AspectHeight.value);var l=a/c,h=45;void 0!==n.FieldOfView&&(h=n.FieldOfView.value);var u=n.FocalLength?n.FocalLength.value:null;switch(o){case 0:i=new THREE.PerspectiveCamera(h,l,r,s),null!==u&&i.setFocalLength(u);break;case 1:i=new THREE.OrthographicCamera(-a/2,a/2,c/2,-c/2,r,s);break;default:console.warn("THREE.FBXLoader: Unknown camera type "+o+"."),i=new THREE.Object3D}}return i}(e,h);break;case"Light":u=function(e,t){var i,n;if(t.children.forEach(function(t){var i=e.Objects.NodeAttribute[t.ID];void 0!==i&&(n=i)}),void 0===n)i=new THREE.Object3D;else{var o;o=void 0===n.LightType?0:n.LightType.value;var r=16777215;void 0!==n.Color&&(r=(new THREE.Color).fromArray(n.Color.value));var s=void 0===n.Intensity?1:n.Intensity.value/100;void 0!==n.CastLightOnObject&&0===n.CastLightOnObject.value&&(s=0);var a=0;void 0!==n.FarAttenuationEnd&&(a=void 0!==n.EnableFarAttenuation&&0===n.EnableFarAttenuation.value?0:n.FarAttenuationEnd.value/1e3);switch(o){case 0:i=new THREE.PointLight(r,s,a,1);break;case 1:i=new THREE.DirectionalLight(r,s);break;case 2:var c=Math.PI/3;void 0!==n.InnerAngle&&(c=THREE.Math.degToRad(n.InnerAngle.value));var l=0;void 0!==n.OuterAngle&&(l=THREE.Math.degToRad(n.OuterAngle.value),l=Math.max(l,1)),i=new THREE.SpotLight(r,s,a,c,l,1);break;default:console.warn("THREE.FBXLoader: Unknown light type "+n.LightType.value+", defaulting to a THREE.PointLight."),i=new THREE.PointLight(r,s)}void 0!==n.CastShadows&&1===n.CastShadows.value&&(i.castShadow=!0)}return i}(e,h);break;case"Mesh":u=function(e,t,i,n){var o,r=null,s=null,a=[];t.children.forEach(function(e){i.has(e.ID)&&(r=i.get(e.ID)),n.has(e.ID)&&a.push(n.get(e.ID))}),a.length>1?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;l<r.length;l+=3)a.set(r[l],r[l+1],r[l+2],"ZYX"),s.setFromEuler(a),void 0!==n&&s.premultiply(n),s.toArray(c,l/3*4);return new THREE.QuaternionKeyframeTrack(e+".quaternion",o,c)}(e.modelName,e.R.curves,e.initialRotation,e.preRotations);void 0!==n&&t.push(n)}if(void 0!==e.S&&Object.keys(e.S.curves).length>0){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<n;o++,r++)e[r]=t[o];return e}t.exports=THREE.FBXLoader=function(e){this.manager=void 0!==e?e:THREE.DefaultLoadingManager},Object.assign(THREE.FBXLoader.prototype,{load:function(e,t,i,n){var o=this,r=THREE.LoaderUtils.extractUrlBase(e),s=new THREE.FileLoader(this.manager);s.setResponseType("arraybuffer"),s.load(e,function(i){try{var s=o.parse(i,r);t(s)}catch(t){window.setTimeout(function(){n&&n(t),o.manager.itemError(e)},0)}},i,n)},parse:function(t,o){var r;if(function(e){var t="Kaydara FBX Binary \0";return e.byteLength>=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;o<i.length;++o)if(t(1)===i[o])return!1;return!0}(c))throw new Error("THREE.FBXLoader: Unknown format.");if(y(c)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+y(c));r=(new p).parse(c)}var h=function(e){var t=new Map;"Connections"in e&&e.Connections.connections.forEach(function(e){var i=e[0],n=e[1],o=e[2];t.has(i)||t.set(i,{parents:[],children:[]});var r={ID:n,relationship:o};t.get(i).parents.push(r),t.has(n)||t.set(n,{parents:[],children:[]});var s={ID:i,relationship:o};t.get(n).children.push(s)});return t}(r),u=e(r),d=n(r,i(r,new THREE.TextureLoader(this.manager).setPath(o),u,h),h),v=s(r,h);return l(r,h,v,a(r,h,v),d)}});var T=[],x={ByPolygonVertex:{Direct:function(e,t,i,n){var o=e*n.dataSize,r=e*n.dataSize+n.dataSize;return w(T,n.buffer,o,r)},IndexToDirect:function(e,t,i,n){var o=n.indices[e],r=o*n.dataSize,s=o*n.dataSize+n.dataSize;return w(T,n.buffer,r,s)}},ByPolygon:{Direct:function(e,t,i,n){var o=t*n.dataSize,r=t*n.dataSize+n.dataSize;return w(T,n.buffer,o,r)},IndexToDirect:function(e,t,i,n){var o=n.indices[t],r=o*n.dataSize,s=o*n.dataSize+n.dataSize;return w(T,n.buffer,r,s)}},ByVertice:{Direct:function(e,t,i,n){var o=i*n.dataSize,r=i*n.dataSize+n.dataSize;return w(T,n.buffer,o,r)}},AllSame:{IndexToDirect:function(e,t,i,n){var o=n.indices[0]*n.dataSize,r=n.indices[0]*n.dataSize+n.dataSize;return w(T,n.buffer,o,r)}}};Object.assign(p.prototype,{getPrevNode:function(){return this.nodeStack[this.currentIndent-2]},getCurrentNode:function(){return this.nodeStack[this.currentIndent-1]},getCurrentProp:function(){return this.currentProp},pushStack:function(e){this.nodeStack.push(e),this.currentIndent+=1},popStack:function(){this.nodeStack.pop(),this.currentIndent-=1},setCurrentProp:function(e,t){this.currentProp=e,this.currentPropName=t},parse:function(e){this.currentIndent=0,this.allNodes=new m,this.nodeStack=[],this.currentProp=[],this.currentPropName="";var t=this,i=e.split("\n");return i.forEach(function(e,n){var o=e.match(/^[\s\t]*;/),r=e.match(/^[\s\t]*$/);if(!o&&!r){var s=e.match("^\\t{"+t.currentIndent+"}(\\w+):(.*){",""),a=e.match("^\\t{"+t.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),c=e.match("^\\t{"+(t.currentIndent-1)+"}}");s?t.parseNodeBegin(e,s):a?t.parseNodeProperty(e,a,i[++n]):c?t.popStack():e.match(/^[^\s\t}]/)&&t.parseNodePropertyContinued(e)}}),this.allNodes},parseNodeBegin:function(e,t){var i=t[1].trim().replace(/^"/,"").replace(/"$/,""),n=t[2].split(",").map(function(e){return e.trim().replace(/^"/,"").replace(/"$/,"")}),o={name:i},r=this.parseNodeAttr(n),s=this.getCurrentNode();0===this.currentIndent?this.allNodes.add(i,o):i in s?("PoseNode"===i?s.PoseNode.push(o):void 0!==s[i].id&&(s[i]={},s[i][s[i].id]=s[i]),""!==r.id&&(s[i][r.id]=o)):"number"==typeof r.id?(s[i]={},s[i][r.id]=o):"Properties70"!==i&&(s[i]="PoseNode"===i?[o]:o),"number"==typeof r.id&&(o.id=r.id),""!==r.name&&(o.attrName=r.name),""!==r.type&&(o.attrType=r.type),this.pushStack(o)},parseNodeAttr:function(e){var t=e[0];""!==e[0]&&(t=parseInt(e[0]),isNaN(t)&&(t=e[0]));var i="",n="";return e.length>1&&(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<o;i++,n++)e[n]=t[i]}(o=[a,c],l=l.map(function(e){return e.trim().replace(/^"/,"")})),void 0===r[n]&&(r[n]=[])}"Node"===n&&(r.id=o),n in r&&Array.isArray(r[n])?r[n].push(o):"a"!==n?r[n]=o:r.a=o,this.setCurrentProp(r,n),"a"===n&&","!==o.slice(-1)&&(r.a=E(o))}else this.parseNodeSpecialProperty(e,n,o)},parseNodePropertyContinued:function(e){var t=this.getCurrentNode();t.a+=e,","!==e.slice(-1)&&(t.a=E(t.a))},parseNodeSpecialProperty:function(e,t,i){var n=i.split('",').map(function(e){return e.trim().replace(/^\"/,"").replace(/\s/,"_")}),o=n[0],r=n[1],s=n[2],a=n[3],c=n[4];switch(r){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":c=parseFloat(c);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":c=E(c)}this.getPrevNode()[o]={type:r,type2:s,flag:a,value:c},this.setCurrentProp(this.getPrevNode(),o)}}),Object.assign(f.prototype,{parse:function(e){var t=new v(e);t.skip(23);var i=t.getUint32();console.log("THREE.FBXLoader: FBX binary version: "+i);for(var n=new m;!this.endOfContent(t);){var o=this.parseNode(t,i);null!==o&&n.add(o.name,o)}return n},endOfContent:function(e){return e.size()%16==0?(e.getOffset()+160+16&-16)>=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;c<o;c++)a.push(this.parseProperty(e));var l=a.length>0?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<e;i++)t.push(this.getBoolean());return t},getUint8:function(){var e=this.dv.getUint8(this.offset);return this.offset+=1,e},getInt16:function(){var e=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,e},getInt32:function(){var e=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,e},getInt32Array:function(e){for(var t=[],i=0;i<e;i++)t.push(this.getInt32());return t},getUint32:function(){var e=this.dv.getUint32(this.offset,this.littleEndian);return this.offset+=4,e},getInt64:function(){var e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),2147483648&t?(t=4294967295&~t,4294967295===(e=4294967295&~e)&&(t=t+1&4294967295),e=e+1&4294967295,-(4294967296*t+e)):4294967296*t+e},getInt64Array:function(e){for(var t=[],i=0;i<e;i++)t.push(this.getInt64());return t},getUint64:function(){var e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),4294967296*t+e},getFloat32:function(){var e=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e},getFloat32Array:function(e){for(var t=[],i=0;i<e;i++)t.push(this.getFloat32());return t},getFloat64:function(){var e=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e},getFloat64Array:function(e){for(var t=[],i=0;i<e;i++)t.push(this.getFloat64());return t},getArrayBuffer:function(e){var t=this.dv.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t},getString:function(e){for(var t=new Uint8Array(e),i=0;i<e;i++)t[i]=this.getUint8();var n=t.indexOf(0);return n>=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<e.byteLength;n++)i+=String.fromCharCode(t[n]);return i},isASCII:function(e){return"ascii"===this.parseHeader(this.bin2str(e)).format},parse:function(e){return e instanceof ArrayBuffer?this.isASCII(e)?this.parseASCII(this.bin2str(e)):this.parseBinary(e):this.parseASCII(e)},parseHeader:function(e){function t(e,t){var i={type:e[0]};return"list"===i.type?(i.name=e[3],i.countType=e[1],i.itemType=e[2]):i.name=e[1],i.name in t&&(i.name=t[i.name]),i}var i="",n=0,o=/ply([\s\S]*)end_header\s/.exec(e);null!==o&&(i=o[1],n=o[0].length);for(var r,s,a={comments:[],elements:[],headerLength:n},c=i.split("\n"),l=void 0,h=0;h<c.length;h++){var u=c[h];if(""!==(u=u.trim()))switch(s=u.split(/\s+/),r=s.shift(),u=s.join(" "),r){case"format":a.format=s[0],a.version=s[1];break;case"comment":a.comments.push(u);break;case"element":void 0!==l&&a.elements.push(l),(l=Object()).name=s[0],l.count=parseInt(s[1]),l.properties=[];break;case"property":l.properties.push(t(s,this.propertyNameMapping));break;default:console.log("unhandled",r,s)}}return void 0!==l&&a.elements.push(l),a},parseASCIINumber:function(e,t){switch(t){case"char":case"uchar":case"short":case"ushort":case"int":case"uint":case"int8":case"uint8":case"int16":case"uint16":case"int32":case"uint32":return parseInt(e);case"float":case"double":case"float32":case"float64":return parseFloat(e)}},parseASCIIElement:function(e,t){for(var i=t.split(/\s+/),n=Object(),o=0;o<e.length;o++)if("list"===e[o].type){for(var r=[],s=this.parseASCIINumber(i.shift(),e[o].countType),a=0;a<s;a++)r.push(this.parseASCIINumber(i.shift(),e[o].itemType));n[e[o].name]=r}else n[e[o].name]=this.parseASCIINumber(i.shift(),e[o].type);return n},parseASCII:function(e){var t,i=new THREE.Geometry,n=this.parseHeader(e),o="";null!==(t=/end_header\s([\s\S]*)$/.exec(e))&&(o=t[1]);var r=o.split("\n"),s=0,a=0;i.useColor=!1;for(var c=0;c<r.length;c++){var l=r[c];if(""!==(l=l.trim())){a>=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;t<e.faces.length;t++)e.faces[t].vertexColors=[e.colors[e.faces[t].a],e.colors[e.faces[t].b],e.colors[e.faces[t].c]];e.elementsNeedUpdate=!0}return e.computeBoundingSphere(),e},handleElement:function(e,t,i){if("vertex"===t){if(e.vertices.push(new THREE.Vector3(i.x,i.y,i.z)),"red"in i&&"green"in i&&"blue"in i){e.useColor=!0;var n=new THREE.Color;n.setRGB(i.red/255,i.green/255,i.blue/255),e.colors.push(n)}}else if("face"===t){var o=i.vertex_indices||i.vertex_index;3===o.length?e.faces.push(new THREE.Face3(o[0],o[1],o[2])):4===o.length&&e.faces.push(new THREE.Face3(o[0],o[1],o[3]),new THREE.Face3(o[1],o[2],o[3]))}},binaryRead:function(e,t,i,n){switch(i){case"int8":case"char":return[e.getInt8(t),1];case"uint8":case"uchar":return[e.getUint8(t),1];case"int16":case"short":return[e.getInt16(t,n),2];case"uint16":case"ushort":return[e.getUint16(t,n),2];case"int32":case"int":return[e.getInt32(t,n),4];case"uint32":case"uint":return[e.getUint32(t,n),4];case"float32":case"float":return[e.getFloat32(t,n),4];case"float64":case"double":return[e.getFloat64(t,n),8]}},binaryReadElement:function(e,t,i,n){for(var o,r=Object(),s=0,a=0;a<i.length;a++)if("list"===i[a].type){var c=[],l=(o=this.binaryRead(e,t+s,i[a].countType,n))[0];s+=o[1];for(var h=0;h<l;h++)o=this.binaryRead(e,t+s,i[a].itemType,n),c.push(o[0]),s+=o[1];r[i[a].name]=c}else o=this.binaryRead(e,t+s,i[a].type,n),r[i[a].name]=o[0],s+=o[1];return[r,s]},parseBinary:function(e){for(var t,i=new THREE.Geometry,n=this.parseHeader(this.bin2str(e)),o="binary_little_endian"===n.format,r=new DataView(e,n.headerLength),s=0,a=0;a<n.elements.length;a++)for(var c=0;c<n.elements[a].count;c++){s+=(t=this.binaryReadElement(r,s,n.elements[a].properties,o))[1];var l=t[0];this.handleElement(i,n.elements[a].name,l)}return this.postProcess(i)}}},{}],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 o(e,t,i){return new i(function(i,o){var r=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(){o(new Error("Script request to "+e+" timed out")),n(s)},r),l=function(e){clearTimeout(e)};a.addEventListener("load",function(e){i({ok:!0}),l(c),n(s)}),a.addEventListener("error",function(t){o(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||{},o(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},o="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)},r=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"};r.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 r.AStarFinder(t),r.Loader.init(),this.setGrid(e)},r.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;t<e.length;t++)this.tileGroup.remove(e[t])},getTileAtCell:function(e){var t=this.grid.cellToHash(e);return e.tile||(void 0!==this.grid.cells[t]?this.grid.cells[t].tile:null)},snapToGrid:function(e){var t=this.grid.pixelToCell(e);e.copy(this.grid.cellToPixel(t))},snapTileToGrid:function(e){if(e.cell)e.position.copy(this.grid.cellToPixel(e.cell));else{var t=this.grid.pixelToCell(e.position);e.position.copy(this.grid.cellToPixel(t))}return e},getRandomTile:function(){var e=r.Tools.randomInt(0,this.tiles.length-1);return this.tiles[e]},findPath:function(e,t,i){return this.finder.findPath(e.cell,t.cell,i,this.grid)},setGrid:function(e){this.group.remove(this.tileGroup),this.grid&&e!==this.grid&&(this.removeAllTiles(),this.tiles.forEach(function(e){this.grid.remove(e.cell),e.dispose()}),this.grid.dispose()),this.grid=e,this.tiles=[],this.tileGroup=new THREE.Object3D,this.group.add(this.tileGroup)},generateOverlay:function(e){var t=new THREE.LineBasicMaterial({color:0,opacity:.3});this.overlay&&this.group.remove(this.overlay),this.overlay=new THREE.Object3D,this.grid.generateOverlay(e,this.overlay,t),this.group.add(this.overlay)},generateTilemap:function(e){this.reset();var t=this.grid.generateTiles(e);this.tiles=t,this.tileGroup=new THREE.Object3D;for(var i=0;i<t.length;i++)this.tileGroup.add(t[i].mesh);this.group.add(this.tileGroup)},reset:function(){this.removeAllTiles(),this.tileGroup&&this.group.remove(this.tileGroup)}},r.Board.prototype.constructor=r.Board,r.Cell=function(e,t,i,n){this.q=e||0,this.r=t||0,this.s=i||0,this.h=n||1,this.tile=null,this.userData={},this.walkable=!0,this._calcCost=0,this._priority=0,this._visited=!1,this._parent=null,this.uniqueID=r.LinkedList.generateID()},r.Cell.prototype={set:function(e,t,i){return this.q=e,this.r=t,this.s=i,this},copy:function(e){return this.q=e.q,this.r=e.r,this.s=e.s,this.h=e.h,this.tile=e.tile||null,this.userData=e.userData||{},this.walkable=e.walkable,this},add:function(e){return this.q+=e.q,this.r+=e.r,this.s+=e.s,this},equals:function(e){return this.q===e.q&&this.r===e.r&&this.s===e.s}},r.Cell.prototype.constructor=r.Cell,r.HexGrid=function(e){e=e||{},this.type=r.HEX,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,i=[];for(t=0;6>t;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;t<this.size+1;t++)for(i=-this.size;i<this.size+1;i++)n=-t-i,Math.abs(t)<=this.size&&Math.abs(i)<=this.size&&Math.abs(n)<=this.size&&(o=new r.Cell(t,i,n),this.add(o))},generateOverlay:function(e,t,i){var n,o,s,a=this.cellShape.createPointsGeometry();for(n=-e;e+1>n;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;t<n.length;t++)(i=new r.Cell).copy(n[t]),this.add(i)},toJSON:function(){var e,t,i={size:this.size,cellSize:this.cellSize,extrudeSettings:this.extrudeSettings,autogenerated:this.autogenerated},n=[];for(t in this.cells)e=this.cells[t],n.push({q:e.q,r:e.r,s:e.s,h:e.h,walkable:e.walkable,userData:e.userData});return i.cells=n,i},_createVertex:function(e){var t=r.TAU/6*e;return new THREE.Vector3(this.cellSize*Math.cos(t),this.cellSize*Math.sin(t),0)},_cubeRound:function(e){var t=Math.round(e.q),i=Math.round(e.r),n=Math.round(e.s),o=Math.abs(t-e.q),r=Math.abs(i-e.r),s=Math.abs(n-e.s);return o>r&&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;t<n.length;t++)(i=new r.Cell).copy(n[t]),this.add(i)},toJSON:function(){var e,t,i={size:this.size,cellSize:this.cellSize,extrudeSettings:this.extrudeSettings,autogenerated:this.autogenerated},n=[];for(t in this.cells)e=this.cells[t],n.push({q:e.q,r:e.r,s:e.s,h:e.h,walkable:e.walkable,userData:e.userData});return i.cells=n,i}},r.SqrGrid.prototype.constructor=r.SqrGrid,r.Tile=function(e){e=e||{};var t={cell:null,geometry:null,material:null};if(!(t=r.Tools.merge(t,e)).cell||!t.geometry)throw new Error("Missing vg.Tile configuration");this.cell=t.cell,this.cell.tile&&this.cell.tile!==this&&this.cell.tile.dispose(),this.cell.tile=this,this.uniqueID=r.Tools.generateID(),this.geometry=t.geometry,this.material=t.material,this.material||(this.material=new THREE.MeshPhongMaterial({color:r.Tools.randomizeRGB("30, 30, 30",13)})),this.objectType=r.TILE,this.entity=null,this.userData={},this.selected=!1,this.highlight="0x0084cc",this.mesh=new THREE.Mesh(this.geometry,this.material),this.mesh.userData.structure=this,this.position=this.mesh.position,this.rotation=this.mesh.rotation,this.rotation.x=-90*r.DEG_TO_RAD,this.mesh.scale.set(t.scale,t.scale,1),this.material.emissive?this._emissive=this.material.emissive.getHex():this._emissive=null},r.Tile.prototype={select:function(){return this.material.emissive&&this.material.emissive.setHex(this.highlight),this.selected=!0,this},deselect:function(){return null!==this._emissive&&this.material.emissive&&this.material.emissive.setHex(this._emissive),this.selected=!1,this},toggle:function(){return this.selected?this.deselect():this.select(),this},dispose:function(){this.cell&&this.cell.tile&&(this.cell.tile=null),this.cell=null,this.position=null,this.rotation=null,this.mesh.parent&&this.mesh.parent.remove(this.mesh),this.mesh.userData.structure=null,this.mesh=null,this.material=null,this.userData=null,this.entity=null,this.geometry=null,this._emissive=null}},r.Tile.prototype.constructor=r.Tile,function(){var e=function(){this.first=null,this.last=null,this.length=0,this.objToNodeMap={},this.uniqueID=Date.now()+""+Math.floor(1e3*Math.random()),this.sortArray=[]};e.generateID=function(){return Math.random().toString(36).slice(2)+Date.now()},(e.prototype={getNode:function(e){return this.objToNodeMap[e.uniqueID]},addNode:function(t){var i=new function(){this.obj=null,this.next=null,this.prev=null,this.free=!0};if(!t.uniqueID)try{t.uniqueID=e.generateID()}catch(e){return console.error("[LinkedList.addNode] obj passed is immutable: cannot attach necessary identifier"),null}return i.obj=t,i.free=!1,this.objToNodeMap[t.uniqueID]=i,i},swapObjects:function(e,t){this.objToNodeMap[e.obj.uniqueID]=null,this.objToNodeMap[t.uniqueID]=e,e.obj=t},add:function(e){var t=this.objToNodeMap[e.uniqueID];if(t){if(!1===t.free)return;t.obj=e,t.free=!1,t.next=null,t.prev=null}else t=this.addNode(e);if(this.first){if(!this.last)throw new Error("[LinkedList.add] No last in the list -- that shouldn't happen here");this.last.next=t,t.prev=this.last,this.last=t,t.next=null}else this.first=t,this.last=t,t.next=null,t.prev=null;this.length++,this.showDebug&&this.dump("after add")},has:function(e){return!!this.objToNodeMap[e.uniqueID]},moveUp:function(e){this.dump("before move up");var t=this.getNode(e);if(!t)throw"Oops, trying to move an object that isn't in the list";if(t.prev){var i=t.prev,n=i.prev;t==this.last&&(this.last=i);var o=t.next;n&&(n.next=t),t.next=i,t.prev=i.prev,i.next=o,i.prev=t,this.first==i&&(this.first=t)}},moveDown:function(e){var t=this.getNode(e);if(!t)throw"Oops, trying to move an object that isn't in the list";if(t.next){var i=t.next;this.moveUp(i.obj),this.last==i&&(this.last=t)}},sort:function(e){var t,i,n=this.sortArray,o=this.first;for(n.length=0;o;)n.push(o.obj),o=o.next;for(this.clear(),n.sort(e),i=n.length,t=0;i>t;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||s<c._calcCost)){if(c._visited=!0,c._parent=o,c._calcCost=s,c._priority=s+n.distance(t,c),c===t)return r.PathUtil.backtrace(t);this.list.add(c)}}return null},compare:function(e,t){return e._priority-t._priority}},r.AStarFinder.prototype.constructor=r.AStarFinder,r.PathUtil={backtrace:function(e){for(var t=[e];e._parent;)e=e._parent,t.push(e);return t.reverse()},biBacktrace:function(e,t){var i=this.backtrace(e),n=this.backtrace(t);return i.concat(n.reverse())},pathLength:function(e){var t,i,n,o,r,s=0;for(t=1;t<e.length;++t)i=e[t-1],n=e[t],o=i[0]-n[0],r=i[1]-n[1],s+=Math.sqrt(o*o+r*r);return s},interpolate:function(e,t,i,n){var o,r,s,a,c,l,h=Math.abs,u=[];for(s=h(i-e),a=h(n-t),o=i>e?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;l<u.length;++l)if(d=u[l],!e.isWalkableAt(d[0],d[1])){p=!0;break}p&&(a=t[c-1],s.push(a),i=a[0],n=a[1])}return s.push([y,g]),s},compressPath:function(e){if(e.length<3)return e;var t,i,n,o,r,s,a=[],c=e[0][0],l=e[0][1],h=e[1][0],u=e[1][1],d=h-c,p=u-l;for(d/=r=Math.sqrt(d*d+p*p),p/=r,a.push([c,l]),s=2;s<e.length;s++)t=h,i=u,n=d,o=p,d=(h=e[s][0])-t,p=(u=e[s][1])-i,p/=r=Math.sqrt(d*d+p*p),((d/=r)!==n||p!==o)&&a.push([t,i]);return a.push([h,u]),a}},r.Loader={manager:null,imageLoader:null,crossOrigin:!1,init:function(e){this.crossOrigin=e||!1,this.manager=new THREE.LoadingManager(function(){},function(){},function(){console.warn("Error loading images")}),this.imageLoader=new THREE.ImageLoader(this.manager),this.imageLoader.crossOrigin=e},loadTexture:function(e,t,i,n){var o=new THREE.Texture(null,t);return this.imageLoader.load(e,function(e){o.image=e,o.needsUpdate=!0,i&&i(o)},null,function(e){n&&n(e)}),o.sourceFile=e,o}},r.MouseCaster=function(e,t,i){this.down=!1,this.rightDown=!1,this.pickedObject=null,this.selectedObject=null,this.allHits=null,this.active=!0,this.shift=!1,this.ctrl=!1,this.wheel=0,this.position=new THREE.Vector3,this.screenPosition=new THREE.Vector2,this.signal=new r.Signal,this.group=e,this._camera=t,this._raycaster=new THREE.Raycaster,this._preventDefault=!1,(i=i||document).addEventListener("mousemove",this._onDocumentMouseMove.bind(this),!1),i.addEventListener("mousedown",this._onDocumentMouseDown.bind(this),!1),i.addEventListener("mouseup",this._onDocumentMouseUp.bind(this),!1),i.addEventListener("mousewheel",this._onMouseWheel.bind(this),!1),i.addEventListener("DOMMouseScroll",this._onMouseWheel.bind(this),!1)},r.MouseCaster.OVER="over",r.MouseCaster.OUT="out",r.MouseCaster.DOWN="down",r.MouseCaster.UP="up",r.MouseCaster.CLICK="click",r.MouseCaster.WHEEL="wheel",r.MouseCaster.prototype={update:function(){if(this.active){this._raycaster.setFromCamera(this.screenPosition,this._camera);var e,t,i=this._raycaster.intersectObject(this.group,!0);i.length>0?(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<<n;r>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){var n=function(){};n.computeCentroids=function(e){var t,i,n;for(t=0,i=e.faces.length;t<i;t++)(n=e.faces[t]).centroid=new THREE.Vector3(0,0,0),n.centroid.add(e.vertices[n.a]),n.centroid.add(e.vertices[n.b]),n.centroid.add(e.vertices[n.c]),n.centroid.divideScalar(3)},n.roundNumber=function(e,t){return Number(e.toFixed(t))},n.sample=function(e){return e[Math.floor(Math.random()*e.length)]},n.mergeVertexIds=function(e,t){var i=[];if(e.forEach(function(e){t.indexOf(e)>=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)},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,o=0;o<e.vertexIds.length;o++){var r,s,a,c=n[e.vertexIds[o]];0===o?(r=e.vertexIds[1],s=e.vertexIds[e.vertexIds.length-1]):o===e.vertexIds.length-1?(r=e.vertexIds[0],s=e.vertexIds[e.vertexIds.length-2]):(r=e.vertexIds[o+1],s=e.vertexIds[o-1]),a=n[s];var l=n[r].clone().sub(c),h=a.clone().sub(c),u=l.angleTo(h);if(u>Math.PI-.01&&u<Math.PI+.01){var d=[];e.neighbours.forEach(function(t){t.vertexIds.includes(e.vertexIds[o])||d.push(t)}),e.neighbours=d}else i.push(e.vertexIds[o])}e.vertexIds=i,this.setPolygonCentroid(e,t)},n.isConvex=function(e,t){var i=t.vertices;if(e.vertexIds.length<3)return!1;for(var n=!0,o=[],r=0;r<e.vertexIds.length;r++){var s,a,c=i[e.vertexIds[r]];0===r?(s=i[e.vertexIds[1]],a=i[e.vertexIds[e.vertexIds.length-1]]):r===e.vertexIds.length-1?(s=i[e.vertexIds[0]],a=i[e.vertexIds[e.vertexIds.length-2]]):(s=i[e.vertexIds[r+1]],a=i[e.vertexIds[r-1]]);var l=s.clone().sub(c),h=a.clone().sub(c),u=l.angleTo(h);if(u===Math.PI||0===u)return!1;var d=l.cross(h).y;o.push(d)}return o.forEach(function(e){0===e&&(n=!1)}),o.forEach(o[0]>0?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,o=e.z-t.z;return i*i+n*n+o*o},n.isPointInPoly=function(e,t){for(var i=!1,n=-1,o=e.length,r=o-1;++n<o;r=n)(e[n].z<=t.z&&t.z<e[r].z||e[r].z<=t.z&&t.z<e[n].z)&&t.x<(e[r].x-e[n].x)*(t.z-e[n].z)/(e[r].z-e[n].z)+e[n].x&&(i=!i);return i},n.isVectorInPolygon=function(e,t,i){var n=1e5,o=-1e5,r=[];return t.vertexIds.forEach(function(e){n=Math.min(i[e].y,n),o=Math.max(i[e].y,o),r.push(i[e])}),!!(e.y<o+.5&&e.y>n-.5&&this.isPointInPoly(r,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 o=function(e){this.content=[],this.scoreFunction=e};o.prototype.push=function(e){this.content.push(e),this.sinkDown(this.content.length-1)},o.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},o.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)<this.scoreFunction(e)?this.sinkDown(t):this.bubbleUp(t))},o.prototype.size=function(){return this.content.length},o.prototype.rescoreElement=function(e){this.sinkDown(this.content.indexOf(e))},o.prototype.sinkDown=function(e){for(var t=this.content[e];e>0;){var i=(e+1>>1)-1,n=this.content[i];if(!(this.scoreFunction(t)<this.scoreFunction(n)))break;this.content[i]=t,this.content[e]=n,e=i}},o.prototype.bubbleUp=function(e){for(var t=this.content.length,i=this.content[e],n=this.scoreFunction(i);;){var o=e+1<<1,r=o-1,s=null,a=void 0;if(r<t&&(a=this.scoreFunction(this.content[r]))<n&&(s=r),o<t&&this.scoreFunction(this.content[o])<(null===s?n:a)&&(s=o),null===s)break;this.content[e]=this.content[s],this.content[s]=i,e=s}};var r=function(){};r.init=function(e){for(var t=0;t<e.length;t++){var i=e[t];i.f=0,i.g=0,i.h=0,i.cost=1,i.visited=!1,i.closed=!1,i.parent=null}},r.cleanUp=function(e){for(var t=0;t<e.length;t++){var i=e[t];delete i.f,delete i.g,delete i.h,delete i.cost,delete i.visited,delete i.closed,delete i.parent}},r.heap=function(){return new o(function(e){return e.f})},r.search=function(e,t,i){this.init(e);var n=this.heap();for(n.push(t);n.size()>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;c<l;c++){var h=a[c];if(!h.closed){var u=o.g+h.cost,d=h.visited;if(!d||u<h.g){if(h.visited=!0,h.parent=o,!h.centroid||!i.centroid)throw new Error("Unexpected state");h.h=h.h||this.heuristic(h.centroid,i.centroid),h.g=u,h.f=h.g+h.h,d?n.rescoreElement(h):n.push(h)}}}}return[]},r.heuristic=function(e,t){return n.distanceToSquared(e,t)},r.neighbours=function(e,t){for(var i=[],n=0;n<t.neighbours.length;n++)i.push(e[t.neighbours[n]]);return i};var s=1,a=function(){};a.buildZone=function(e){var t=this,i=this._buildNavigationMesh(e),o={};i.vertices.forEach(function(e){e.x=n.roundNumber(e.x,2),e.y=n.roundNumber(e.y,2),e.z=n.roundNumber(e.z,2)}),o.vertices=i.vertices;var r=this._buildPolygonGroups(i);o.groups=[];var s=function(e,t){for(var i=0;i<e.length;i++)if(t===e[i])return i};return r.forEach(function(e){var i=[];e.forEach(function(o){var r=o.neighbours.map(function(t){return s(e,t)}),a=o.neighbours.map(function(e){return t._getSharedVerticesInOrder(o,e)});o.centroid.x=n.roundNumber(o.centroid.x,2),o.centroid.y=n.roundNumber(o.centroid.y,2),o.centroid.z=n.roundNumber(o.centroid.z,2),i.push({id:s(e,o),neighbours:r,vertexIds:o.vertexIds,centroid:o.centroid,portals:a})}),o.groups.push(i)}),o},a._buildNavigationMesh=function(e){return n.computeCentroids(e),e.mergeVertices(),this._buildPolygonsFromGeometry(e)},a._buildPolygonGroups=function(e){var t=[],i=0,n=function(e){e.neighbours.forEach(function(t){void 0===t.group&&(t.group=e.group,n(t))})};return e.polygons.forEach(function(e){void 0===e.group&&(e.group=i++,n(e)),t[e.group]||(t[e.group]=[]),t[e.group].push(e)}),t},a._buildPolygonNeighbours=function(e,t,i){var n=new Set,o=i.get(e.vertexIds[0]),r=i.get(e.vertexIds[1]),s=i.get(e.vertexIds[2]);o.forEach(function(e){(r.has(e)||s.has(e))&&n.add(t.polygons[e])}),r.forEach(function(e){s.has(e)&&n.add(t.polygons[e])}),e.neighbours=Array.from(n)},a._buildPolygonsFromGeometry=function(e){for(var t=this,i=[],n=e.vertices,o=e.faceVertexUvs,r=new Map,a=0;a<n.length;a++)r.set(a,new Set);e.faces.forEach(function(e){i.push({id:s++,vertexIds:[e.a,e.b,e.c],centroid:e.centroid,normal:e.normal,neighbours:[]}),r.get(e.a).add(i.length-1),r.get(e.b).add(i.length-1),r.get(e.c).add(i.length-1)});var c={polygons:i,vertices:n,faceVertexUvs:o};return i.forEach(function(e){t._buildPolygonNeighbours(e,c,r)}),c},a._getSharedVerticesInOrder=function(e,t){var i=e.vertexIds,n=t.vertexIds,o=new Set;if(i.forEach(function(e){n.includes(e)&&o.add(e)}),o.size<2)return[];o.has(i[0])&&o.has(i[i.length-1])&&i.push(i.shift()),o.has(n[0])&&o.has(n[n.length-1])&&n.push(n.shift());var r=[];return i.forEach(function(e){n.includes(e)&&r.push(e)}),r};var c=function(){this.portals=[]};c.prototype.push=function(e,t){void 0===t&&(t=e),this.portals.push({left:e,right:t})},c.prototype.stringPull=function(){var e,t,i,o=this.portals,r=[],s=0,a=0,c=0;t=o[0].left,i=o[0].right,r.push(e=o[0].left);for(var l=1;l<o.length;l++){var h=o[l].left,u=o[l].right;if(n.triarea2(e,i,u)<=0){if(!(n.vequal(e,i)||n.triarea2(e,t,u)>0)){r.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)){r.push(i),t=e=i,i=e,a=s=c,c=s,l=s;continue}t=h,a=l}}return 0!==r.length&&n.vequal(r[r.length-1],o[o.length-1].left)||r.push(o[o.length-1].left),this.path=r,r};var l,h,u,d,p,f,v=function(){this.zones={}};v.createZone=function(e){return a.buildZone(e)},v.prototype.setZoneData=function(e,t){this.zones[e]=t},v.prototype.getGroup=function(e,t){if(!this.zones[e])return null;var i=null,o=Math.pow(50,2);return this.zones[e].groups.forEach(function(e,r){e.forEach(function(e){var s=n.distanceToSquared(e.centroid,t);s<o&&(i=r,o=s)})}),i},v.prototype.getRandomNode=function(e,t,i,o){if(!this.zones[e])return new THREE.Vector3;i=i||null,o=o||0;var r=[];return this.zones[e].groups[t].forEach(function(e){i&&o?n.distanceToSquared(i,e.centroid)<o*o&&r.push(e.centroid):r.push(e.centroid)}),n.sample(r)||new THREE.Vector3},v.prototype.getClosestNode=function(e,t,i,o){void 0===o&&(o=!1);var r=this.zones[t].vertices,s=null,a=1/0;return this.zones[t].groups[i].forEach(function(t){var i=n.distanceToSquared(t.centroid,e);i<a&&(!o||n.isVectorInPolygon(e,t,r))&&(s=t,a=i)}),s},v.prototype.findPath=function(e,t,i,n){var o=this.zones[i].groups[n],s=this.zones[i].vertices,a=this.getClosestNode(e,i,n),l=this.getClosestNode(t,i,n,!0);if(!a||!l)return null;var h=r.search(o,a,l),u=function(e,t){for(var i=0;i<e.neighbours.length;i++)if(e.neighbours[i]===t.id)return e.portals[i]},d=new c;d.push(e);for(var p=0;p<h.length;p++){var f=h[p+1];if(f){var v=u(h[p],f);d.push(s[v[0]],s[v[1]])}}d.push(t),d.stringPull();var m=d.path.map(function(e){return new THREE.Vector3(e.x,e.y,e.z)});return m.shift(),m},v.prototype.clampStep=(u=new THREE.Vector3,d=new THREE.Plane,p=new THREE.Triangle,f=new THREE.Vector3,function(e,t,i,n,o,r){var s=this.zones[n].vertices,a=this.zones[n].groups[o],c=[i],v={};v[i.id]=0,l=void 0,f.set(0,0,0),h=1/0,d.setFromCoplanarPoints(s[i.vertexIds[0]],s[i.vertexIds[1]],s[i.vertexIds[2]]),d.projectPoint(t,u),t.copy(u);for(var m=c.pop();m;m=c.pop()){p.set(s[m.vertexIds[0]],s[m.vertexIds[1]],s[m.vertexIds[2]]),p.closestPointToPoint(t,u),u.distanceToSquared(t)<h&&(l=m,f.copy(u),h=u.distanceToSquared(t));var y=v[m];if(!(y>2))for(var g=0;g<m.neighbours.length;g++){var E=a[m.neighbours[g]];E.id in v||(c.push(E),v[E.id]=y+1)}}return r.copy(f),l}),i.Pathfinding=v},{}],12:[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)}})},{}],13:[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<e.buttons.length;t++)e.buttons[t].pressed&&!this.buttons[t]?this.emit(new o("gamepadbuttondown",t,e.buttons[t])):!e.buttons[t].pressed&&this.buttons[t]&&this.emit(new o("gamepadbuttonup",t,e.buttons[t])),this.buttons[t]=e.buttons[t].pressed;else Object.keys(this.buttons)&&(this.buttons={})},emit:function(e){this.el.emit(e.type,e),this.el.emit(e.type+":"+e.index,new o(e.type,e.index,e))},getGamepad:function(){var e=navigator.getGamepads&&navigator.getGamepads()[this.data.controller],t=this.el.sceneEl.components["proxy-controls"];return t&&t.isConnected()&&t.getGamepad(this.data.controller)||e},getButton:function(e){return this.getGamepad().buttons[e]},getAxis:function(e){return this.getGamepad().axes[e]},getJoystick:function(e){var t=this.getGamepad();switch(e){case 0:return new THREE.Vector2(t.axes[0],t.axes[1]);case 1:return new THREE.Vector2(t.axes[2],t.axes[3]);default:throw new Error('Unexpected joystick index "%d".',e)}},getDpad:function(){var e=this.getGamepad();return e.buttons[n.DPAD_RIGHT]?new THREE.Vector2((e.buttons[n.DPAD_RIGHT].pressed?1:0)+(e.buttons[n.DPAD_LEFT].pressed?-1:0),(e.buttons[n.DPAD_UP].pressed?-1:0)+(e.buttons[n.DPAD_DOWN].pressed?1:0)):new THREE.Vector2},isConnected:function(){var e=this.getGamepad();return!(!e||!e.connected)},getID:function(){return this.getGamepad().id}})},{"../../lib/GamepadButton":4,"../../lib/GamepadButtonEvent":5}],14:[function(e,t,i){"use strict";e("./checkpoint-controls"),e("./gamepad-controls"),e("./keyboard-controls"),e("./touch-controls"),e("./movement-controls"),e("./trackpad-controls")},{"./checkpoint-controls":12,"./gamepad-controls":13,"./keyboard-controls":15,"./movement-controls":16,"./touch-controls":17,"./trackpad-controls":18}],15:[function(e,t,i){"use strict";e("../../lib/keyboard.polyfill");var n=window.KeyboardEvent;t.exports=AFRAME.registerComponent("keyboard-controls",{schema:{enabled:{default:!0},debug:{default:!1}},init:function(){this.dVelocity=new THREE.Vector3,this.localKeys={},this.listeners={keydown:this.onKeyDown.bind(this),keyup:this.onKeyUp.bind(this),blur:this.onBlur.bind(this)},this.attachEventListeners()},isVelocityActive:function(){return this.data.enabled&&!!Object.keys(this.getKeys()).length},getVelocityDelta:function(){var e=this.data,t=this.getKeys();return this.dVelocity.set(0,0,0),e.enabled&&((t.KeyW||t.ArrowUp)&&(this.dVelocity.z-=1),(t.KeyA||t.ArrowLeft)&&(this.dVelocity.x-=1),(t.KeyS||t.ArrowDown)&&(this.dVelocity.z+=1),(t.KeyD||t.ArrowRight)&&(this.dVelocity.x+=1)),this.dVelocity.clone()},play:function(){this.attachEventListeners()},pause:function(){this.removeEventListeners()},remove:function(){this.pause()},attachEventListeners:function(){window.addEventListener("keydown",this.listeners.keydown,!1),window.addEventListener("keyup",this.listeners.keyup,!1),window.addEventListener("blur",this.listeners.blur,!1)},removeEventListeners:function(){window.removeEventListener("keydown",this.listeners.keydown),window.removeEventListener("keyup",this.listeners.keyup),window.removeEventListener("blur",this.listeners.blur)},onKeyDown:function(e){AFRAME.utils.shouldCaptureKeyEvent(e)&&(this.localKeys[e.code]=!0,this.emit(e))},onKeyUp:function(e){AFRAME.utils.shouldCaptureKeyEvent(e)&&(delete this.localKeys[e.code],this.emit(e))},onBlur:function(){for(var e in this.localKeys)this.localKeys.hasOwnProperty(e)&&delete this.localKeys[e]},emit:function(e){"__keyboard-controls-proxy"in e&&this.el.emit(e.type,e),this.el.emit(e.type+":"+e.code,new n(e.type,e)),this.data.debug&&console.log(e.type+":"+e.code)},isPressed:function(e){return e in this.getKeys()},getKeys:function(){return this.isProxied()?this.el.sceneEl.components["proxy-controls"].getKeyboard():this.localKeys},isProxied:function(){var e=this.el.sceneEl.components["proxy-controls"];return e&&e.isConnected()}})},{"../../lib/keyboard.polyfill":10}],16:[function(e,t,i){"use strict";t.exports=AFRAME.registerComponent("movement-controls",{dependencies:["rotation"],schema:{enabled:{default:!0},controls:{default:["gamepad","trackpad","keyboard","touch"]},speed:{default:.3,min:0},fly:{default:!1},constrainToNavMesh:{default:!1},camera:{default:"[camera]",type:"selector"}},init:function(){var e=this.el;this.velocityCtrl=null,this.velocity=new THREE.Vector3,this.heading=new THREE.Quaternion,this.navGroup=null,this.navNode=null,e.sceneEl.hasLoaded?this.injectControls():e.sceneEl.addEventListener("loaded",this.injectControls.bind(this))},update:function(e){var t=this.el,i=this.data,n=t.sceneEl.systems.nav;t.sceneEl.hasLoaded&&this.injectControls(),n&&i.constrainToNavMesh!==e.constrainToNavMesh&&(i.constrainToNavMesh?n.addAgent(this):n.removeAgent(this))},injectControls:function(){for(var e,t=this.data,i=0;i<t.controls.length;i++)e=t.controls[i]+"-controls",this.el.components[e]||this.el.setAttribute(e,"")},updateNavLocation:function(){this.navGroup=null,this.navNode=null},tick:function(){var e=new THREE.Vector3,t=new THREE.Vector3,i=new THREE.Vector3;return function(n,o){if(o){var r=this.el,s=this.data;if(s.enabled){this.updateVelocityCtrl();var a=this.velocityCtrl,c=this.velocity;if(a)if(o/1e3>.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;t<i;t++){var n=this.el.components[e.controls[t]+"-controls"];if(n&&n.isVelocityActive())return void(this.velocityCtrl=n)}this.velocityCtrl=null}},updateVelocity:function(){var e=new THREE.Vector2;return function(t){var i=void 0,n=this.el,o=this.velocityCtrl,r=this.velocity,s=this.data;if(o){if(!o.getVelocityDelta){if(o.getVelocity)return void r.copy(o.getVelocity());if(o.getPositionDelta)return void r.copy(o.getPositionDelta(t).multiplyScalar(1e3/t));throw new Error("Incompatible movement controls: ",o)}i=o.getVelocityDelta(t)}if(n.hasAttribute("velocity")&&!s.constrainToNavMesh&&r.copy(this.el.getAttribute("velocity")),i&&s.enabled){var a=s.camera;i.applyQuaternion(a.object3D.quaternion);var c=i.length();s.fly?(r.copy(i),r.multiplyScalar(this.data.speed*t)):(e.set(i.x,i.z),e.setLength(c*this.data.speed*t),r.x=e.x,r.z=e.y)}}}()})},{}],17:[function(e,t,i){"use strict";t.exports=AFRAME.registerComponent("touch-controls",{schema:{enabled:{default:!0}},init:function(){this.dVelocity=new THREE.Vector3,this.bindMethods()},play:function(){this.addEventListeners()},pause:function(){this.removeEventListeners(),this.dVelocity.set(0,0,0)},remove:function(){this.pause()},addEventListeners:function(){var e=this.el.sceneEl,t=e.canvas;t?(t.addEventListener("touchstart",this.onTouchStart),t.addEventListener("touchend",this.onTouchEnd)):e.addEventListener("render-target-loaded",this.addEventListeners.bind(this))},removeEventListeners:function(){var e=this.el.sceneEl&&this.el.sceneEl.canvas;e&&(e.removeEventListener("touchstart",this.onTouchStart),e.removeEventListener("touchend",this.onTouchEnd))},isVelocityActive:function(){return this.data.enabled&&this.isMoving},getVelocityDelta:function(){return this.dVelocity.z=this.isMoving?-1:0,this.dVelocity.clone()},bindMethods:function(){this.onTouchStart=this.onTouchStart.bind(this),this.onTouchEnd=this.onTouchEnd.bind(this)},onTouchStart:function(e){this.isMoving=!0,e.preventDefault()},onTouchEnd:function(e){this.isMoving=!1,e.preventDefault()}})},{}],18:[function(e,t,i){"use strict";t.exports=AFRAME.registerComponent("trackpad-controls",{schema:{enabled:{default:!0}},init:function(){this.dVelocity=new THREE.Vector3,this.zVel=0,this.bindMethods()},play:function(){this.addEventListeners()},pause:function(){this.removeEventListeners(),this.dVelocity.set(0,0,0)},remove:function(){this.pause()},addEventListeners:function(){var e=this.el.sceneEl;e.addEventListener("axismove",this.onAxisMove),e.addEventListener("trackpadtouchstart",this.onTouchStart),e.addEventListener("trackpadtouchend",this.onTouchEnd)},removeEventListeners:function(){var e=this.el.sceneEl;e.removeEventListener("axismove",this.onAxisMove),e.removeEventListener("trackpadtouchstart",this.onTouchStart),e.removeEventListener("trackpadtouchend",this.onTouchEnd)},isVelocityActive:function(){return this.data.enabled&&this.isMoving},getVelocityDelta:function(){return this.dVelocity.z=this.isMoving?-this.zVel:1,this.dVelocity.clone()},bindMethods:function(){this.onTouchStart=this.onTouchStart.bind(this),this.onTouchEnd=this.onTouchEnd.bind(this),this.onAxisMove=this.onAxisMove.bind(this)},onTouchStart:function(e){this.isMoving=!0,e.preventDefault()},onTouchEnd:function(e){this.isMoving=!1,e.preventDefault()},onAxisMove:function(e){var t=e.detail.axis;t[1]<0&&(this.zVel=1),t[1]>0&&(this.zVel=-1)}})},{}],19:[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},clampWhenFinished:{default:!1,type:"boolean"},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;t<this.activeActions.length;t++)e.crossFadeDuration?this.activeActions[t].fadeOut(e.crossFadeDuration):this.activeActions[t].stop();this.activeActions.length=0},playAction:function(){if(this.mixer){var e=this.model,t=this.data,i=e.animations||(e.geometry||{}).animations||[];if(i.length)for(var r,s=function(e){return new RegExp("^"+e.split(/\*+/).map(n).join(".*")+"$")}(t.clip),a=0;r=i[a];a++)if(r.name.match(s)){var c=this.mixer.clipAction(r,e);c.enabled=!0,c.clampWhenFinished=t.clampWhenFinished,t.duration&&c.setDuration(t.duration),c.setLoop(o[t.loop],t.repetitions).fadeIn(t.crossFadeDuration).play(),this.activeActions.push(c)}}},tick:function(e,t){this.mixer&&!isNaN(t)&&this.mixer.update(t/1e3)}})},{}],20:[function(e,t,i){"use strict";THREE.FBXLoader=e("../../lib/FBXLoader"),t.exports=AFRAME.registerComponent("fbx-model",{schema:{src:{type:"asset"},crossorigin:{default:""}},init:function(){this.model=null},update:function(){var e=this.data;if(e.src){this.remove();var t=new THREE.FBXLoader;e.crossorigin&&t.setCrossOrigin(e.crossorigin),t.load(e.src,this.load.bind(this))}},load:function(e){this.model=e,this.el.setObject3D("mesh",e),this.el.emit("model-loaded",{format:"fbx",model:e})},remove:function(){this.model&&this.el.removeObject3D("mesh")}})},{"../../lib/FBXLoader":3}],21:[function(e,t,i){"use strict";var n=e("../../lib/fetch-script")(),o=function(){var e=void 0;return function(){return e=e||n("https://rawgit.com/mrdoob/three.js/r86/examples/js/loaders/GLTFLoader.js")}}();t.exports=AFRAME.registerComponent("gltf-model-legacy",{schema:{type:"model"},init:function(){var e=this;this.model=null,this.loader=null,this.loaderPromise=o().then(function(){e.loader=new THREE.GLTFLoader,e.loader.setCrossOrigin("Anonymous")})},update:function(){var e=this,t=this,i=this.el,n=this.data;n&&(this.remove(),this.loaderPromise.then(function(){e.loader.load(n,function(e){t.model=e.scene,t.model.animations=e.animations,i.setObject3D("mesh",t.model),i.emit("model-loaded",{format:"gltf",model:t.model})})}))},remove:function(){this.model&&this.el.removeObject3D("mesh")}})},{"../../lib/fetch-script":8}],22:[function(e,t,i){"use strict";e("./animation-mixer"),e("./fbx-model"),e("./gltf-model-legacy"),e("./json-model"),e("./object-model"),e("./ply-model")},{"./animation-mixer":19,"./fbx-model":20,"./gltf-model-legacy":21,"./json-model":23,"./object-model":24,"./ply-model":25}],23:[function(e,t,i){"use strict";t.exports=AFRAME.registerComponent("json-model",{schema:{src:{type:"asset"},crossorigin:{default:""}},init:function(){this.model=null},update:function(){var e=this,t=void 0,i=this.data;i.src&&(this.remove(),t=new THREE.JSONLoader,i.crossorigin&&(t.crossOrigin=i.crossorigin),t.load(i.src,function(t,i){i.forEach(function(e){e.vertexColors=(t.faces[0]||{}).color?THREE.FaceColors:THREE.NoColors,e.skinning=!!(t.bones||[]).length,e.morphTargets=!!(t.morphTargets||[]).length,e.morphNormals=!!(t.morphNormals||[]).length});var n=(t.bones||[]).length?new THREE.SkinnedMesh(t,new THREE.MultiMaterial(i)):new THREE.Mesh(t,new THREE.MultiMaterial(i));e.load(n)}))},load:function(e){this.model=e,this.el.setObject3D("mesh",e),this.el.emit("model-loaded",{format:"json",model:e})},remove:function(){this.model&&this.el.removeObject3D("mesh")}})},{}],24:[function(e,t,i){"use strict";t.exports=AFRAME.registerComponent("object-model",{schema:{src:{type:"asset"},crossorigin:{default:""}},init:function(){this.model=null},update:function(){var e=this,t=void 0,i=this.data;i.src&&(this.remove(),t=new THREE.ObjectLoader,i.crossorigin&&t.setCrossOrigin(i.crossorigin),t.load(i.src,function(t){t.traverse(function(e){e instanceof THREE.SkinnedMesh&&e.material&&(e.material.skinning=!!(e.geometry&&e.geometry.bones||[]).length)}),e.load(t)}))},load:function(e){this.model=e,this.el.setObject3D("mesh",e),this.el.emit("model-loaded",{format:"json",model:e})},remove:function(){this.model&&this.el.removeObject3D("mesh")}})},{}],25:[function(e,t,i){"use strict";THREE.PLYLoader=e("../../lib/PLYLoader"),t.exports.System=AFRAME.registerSystem("ply-model",{init:function(){this.cache={}},getOrLoadGeometry:function(e,t){var i=this.cache,n=i[e];return!t&&n?n:(i[e]=new Promise(function(t){(new THREE.PLYLoader).load(e,function(e){t(e)})}),i[e])}}),t.exports.Component=AFRAME.registerComponent("ply-model",{schema:{skipCache:{type:"boolean",default:!1},src:{type:"asset"}},init:function(){this.model=null},update:function(){var e=this.data,t=this.el;e.src?this.system.getOrLoadGeometry(e.src,e.skipCache).then(function(e){var i=function(e){return new THREE.Mesh(e,new THREE.MeshPhongMaterial({color:16777215,shading:THREE.FlatShading,vertexColors:THREE.VertexColors,shininess:0}))}(e);t.setObject3D("mesh",i),t.emit("model-loaded",{format:"ply",model:i})}):console.warn("[%s] `src` property is required.",this.name)},remove:function(){this.model&&this.el.removeObject3D("mesh")}})},{"../../lib/PLYLoader":6}],26:[function(e,t,i){"use strict";t.exports=AFRAME.registerComponent("checkpoint",{schema:{offset:{default:{x:0,y:0,z:0},type:"vec3"}},init:function(){this.active=!1,this.targetEl=null,this.fire=this.fire.bind(this),this.offset=new THREE.Vector3},update:function(){this.offset.copy(this.data.offset)},play:function(){this.el.addEventListener("click",this.fire)},pause:function(){this.el.removeEventListener("click",this.fire)},remove:function(){this.pause()},fire:function(){var e=this.el.sceneEl.querySelector("[checkpoint-controls]");if(!e)throw new Error("No `checkpoint-controls` component found.");e.components["checkpoint-controls"].setCheckpoint(this.el)},getOffset:function(){return this.offset.copy(this.data.offset)}})},{}],27:[function(e,t,i){"use strict";function n(e,t,i,n){e&&(t=t||[],e.traverse(function(e){if(e.isMesh){(function(e){return e?Array.isArray(e)?e:e.materials?e.materials:[e]:[]})(e.material).forEach(function(e){(!e||"envMap"in e)&&(t.length&&-1===t.indexOf(e.name)||(e.envMap=i,e.reflectivity=n,e.needsUpdate=!0))})}}))}t.exports=AFRAME.registerComponent("cube-env-map",{multiple:!0,schema:{path:{default:""},extension:{default:"jpg",oneOf:["jpg","png"]},format:{default:"RGBFormat",oneOf:["RGBFormat","RGBAFormat"]},enableBackground:{default:!1},reflectivity:{default:1,min:0,max:1},materials:{default:[]}},init:function(){var e=this,t=this.data;this.texture=(new THREE.CubeTextureLoader).load([t.path+"posx."+t.extension,t.path+"negx."+t.extension,t.path+"posy."+t.extension,t.path+"negy."+t.extension,t.path+"posz."+t.extension,t.path+"negz."+t.extension]),this.texture.format=THREE[t.format],this.object3dsetHandler=function(){var t=e.el.getObject3D("mesh"),i=e.data;n(t,i.materials,e.texture,i.reflectivity)},this.el.addEventListener("object3dset",this.object3dsetHandler)},update:function(e){var t=this.data,i=this.el.getObject3D("mesh"),o=[],r=[];if(t.materials.length&&(e.materials?(o=t.materials.filter(function(t){return!e.materials.includes(t)}),r=e.materials.filter(function(e){return!t.materials.includes(e)})):o=t.materials),o.length&&n(i,o,this.texture,t.reflectivity),r.length&&n(i,r,null,1),e.materials&&t.reflectivity!==e.reflectivity){var s=t.materials.filter(function(t){return e.materials.includes(t)});s.length&&n(i,s,this.texture,t.reflectivity)}this.data.enableBackground&&!e.enableBackground?this.setBackground(this.texture):!this.data.enableBackground&&e.enableBackground&&this.setBackground(null)},remove:function(){this.el.removeEventListener("object3dset",this.object3dsetHandler);var e=this.el.getObject3D("mesh"),t=this.data;n(e,t.materials,null,1),t.enableBackground&&this.setBackground(null)},setBackground:function(e){this.el.sceneEl.object3D.background=e}})},{}],28:[function(e,t,i){"use strict";t.exports=AFRAME.registerComponent("grab",{init:function(){this.system=this.el.sceneEl.systems.physics,this.GRABBED_STATE="grabbed",this.grabbing=!1,this.hitEl=null,this.physics=this.el.sceneEl.systems.physics,this.constraint=null,this.onHit=this.onHit.bind(this),this.onGripOpen=this.onGripOpen.bind(this),this.onGripClose=this.onGripClose.bind(this)},play:function(){var e=this.el;e.addEventListener("hit",this.onHit),e.addEventListener("gripdown",this.onGripClose),e.addEventListener("gripup",this.onGripOpen),e.addEventListener("trackpaddown",this.onGripClose),e.addEventListener("trackpadup",this.onGripOpen),e.addEventListener("triggerdown",this.onGripClose),e.addEventListener("triggerup",this.onGripOpen)},pause:function(){var e=this.el;e.removeEventListener("hit",this.onHit),e.removeEventListener("gripdown",this.onGripClose),e.removeEventListener("gripup",this.onGripOpen),e.removeEventListener("trackpaddown",this.onGripClose),e.removeEventListener("trackpadup",this.onGripOpen),e.removeEventListener("triggerdown",this.onGripClose),e.removeEventListener("triggerup",this.onGripOpen)},onGripClose:function(){this.grabbing=!0},onGripOpen:function(){var e=this.hitEl;this.grabbing=!1,e&&(e.removeState(this.GRABBED_STATE),this.hitEl=void 0,this.system.removeConstraint(this.constraint),this.constraint=null)},onHit:function(e){var t=e.detail.el;t&&!t.is(this.GRABBED_STATE)&&this.grabbing&&!this.hitEl&&(t.addState(this.GRABBED_STATE),this.hitEl=t,this.constraint=new CANNON.LockConstraint(this.el.body,t.body),this.system.addConstraint(this.constraint))}})},{}],29:[function(e,t,i){"use strict";e("./checkpoint"),e("./cube-env-map"),e("./grab"),e("./jump-ability"),e("./kinematic-body"),e("./mesh-smooth"),e("./normal-material"),e("./sphere-collider")},{"./checkpoint":26,"./cube-env-map":27,"./grab":28,"./jump-ability":30,"./kinematic-body":31,"./mesh-smooth":32,"./normal-material":33,"./sphere-collider":34}],30:[function(e,t,i){"use strict";t.exports=AFRAME.registerComponent("jump-ability",{dependencies:["velocity"],schema:{on:{default:"keydown:Space gamepadbuttondown:0"},playerHeight:{default:1.764},maxJumps:{default:1},distance:{default:5},debug:{default:!1}},init:function(){this.velocity=0,this.numJumps=0;var e=this.beginJump.bind(this),t=this.data.on.split(" ");this.bindings={};for(var i=0;i<t.length;i++)this.bindings[t[i]]=e,this.el.addEventListener(t[i],e);this.bindings.collide=this.onCollide.bind(this),this.el.addEventListener("collide",this.bindings.collide)},remove:function(){for(var e in this.bindings)this.bindings.hasOwnProperty(e)&&(this.el.removeEventListener(e,this.bindings[e]),delete this.bindings[e]);this.el.removeEventListener("collide",this.bindings.collide),delete this.bindings.collide},beginJump:function(){if(this.numJumps<this.data.maxJumps){var e=this.data,t=Math.sqrt(-2*e.distance*-24.8),i=this.el.getAttribute("velocity");this.el.setAttribute("velocity",{x:i.x,y:t,z:i.z}),this.numJumps++,this.el.emit("jumpstart")}},onCollide:function(){this.numJumps>0&&this.el.emit("jumpend"),this.numJumps=0}})},{}],31:[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}})},{}],32:[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()})})}})},{}],33:[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)})}})},{}],34:[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))<o+a&&(s.push(i),n.set(i,c)))}),s.sort(function(e,t){return n.get(e)>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})}})},{}],35:[function(e,t,i){"use strict";e("./nav-mesh"),e("./nav-agent"),e("./system")},{"./nav-agent":36,"./nav-mesh":37,"./system":38}],36:[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()<c){if(this.path.shift(),!this.path.length)return this.el.setAttribute("nav-agent",{active:!1}),void r.emit("nav-end");i.copy(h),d=this.path[0]}else i.copy(t.setLength(c)).add(h),d=u;d.y=h.y,r.object3D.lookAt(d),a.ray.origin.copy(i),a.ray.origin.y+=1.5,a.ray.direction.y=-1;var p=a.intersectObject(this.system.getNavMesh());p.length?(t.subVectors(p[0].point,h),h.add(t.setLength(c))):h.copy(i)}}}()})},{}],37:[function(e,t,i){"use strict";t.exports=AFRAME.registerComponent("nav-mesh",{init:function(){this.system=this.el.sceneEl.systems.nav,this.hasLoadedNavMesh=!1,this.el.addEventListener("model-loaded",this.loadNavMesh.bind(this))},play:function(){this.hasLoadedNavMesh||this.loadNavMesh()},loadNavMesh:function(){var e=this.el.getObject3D("mesh"),t=this.el.sceneEl.object3D;if(e){var i=void 0;if(e.traverse(function(e){e.isMesh&&(i=e)}),i){var n=i.geometry.isBufferGeometry?(new THREE.Geometry).fromBufferGeometry(i.geometry):i.geometry.clone();t.updateMatrixWorld(),n.applyMatrix(i.matrixWorld),this.system.setNavMeshGeometry(n),this.hasLoadedNavMesh=!0}}}})},{}],38:[function(e,t,i){"use strict";var n=e("three-pathfinding").Pathfinding,o=new n,r="level";t.exports=AFRAME.registerSystem("nav",{init:function(){this.navMesh=null,this.agents=new Set},setNavMeshGeometry:function(e){this.navMesh=new THREE.Mesh(e),o.setZoneData(r,n.createZone(e)),Array.from(this.agents).forEach(function(e){return e.updateNavLocation()})},getNavMesh:function(){return this.navMesh},addAgent:function(e){this.agents.add(e)},removeAgent:function(e){this.agents.delete(e)},getPath:function(e,t,i){return this.navMesh?o.findPath(e,t,r,i):null},getGroup:function(e){return this.navMesh?o.getGroup(r,e):null},getNode:function(e,t){return this.navMesh?o.getClosestNode(e,r,t,!0):null},clampStep:function(e,t,i,n,s){return this.navMesh?n?o.clampStep(e,t,n,r,i,s):(s.copy(t),this.getNode(t,i)):(s.copy(t),null)}})},{"three-pathfinding":11}],39:[function(e,t,i){"use strict";t.exports=AFRAME.registerPrimitive("a-grid",{defaultComponents:{geometry:{primitive:"plane",width:75,height:75},rotation:{x:-90,y:0,z:0},material:{src:"url(https://cdn.rawgit.com/donmccurdy/aframe-extras/v1.16.3/assets/grid.png)",repeat:"75 75"}},mappings:{width:"geometry.width",height:"geometry.height",src:"material.src"}})},{}],40:[function(e,t,i){"use strict";var n=e("../../lib/hex-grid.min.js"),o=e("../../lib/default-hex-grid");t.exports.Primitive=AFRAME.registerPrimitive("a-hexgrid",{defaultComponents:{hexgrid:{}},mappings:{src:"hexgrid.src"}}),t.exports.Component=AFRAME.registerComponent("hexgrid",{dependencies:["material"],schema:{src:{type:"asset"}},init:function(){var e=this,t=this.data;t.src?fetch(t.src).then(function(e){return e.json()}).then(function(t){return e.addMesh(t)}):this.addMesh(o)},addMesh:function(e){var t=new n.HexGrid;t.fromJSON(e);var i=new n.Board(t);i.generateTilemap(),this.el.setObject3D("mesh",i.group),this.addMaterial()},addMaterial:function(){var e=(this.el.components.material||{}).material;e&&this.el.object3D.traverse(function(t){t.isMesh&&(t.material=e)})},remove:function(){this.el.removeObject3D("mesh")}})},{"../../lib/default-hex-grid":7,"../../lib/hex-grid.min.js":9}],41:[function(e,t,i){"use strict";t.exports.Primitive=AFRAME.registerPrimitive("a-ocean",{defaultComponents:{ocean:{},rotation:{x:-90,y:0,z:0}},mappings:{width:"ocean.width",depth:"ocean.depth",density:"ocean.density",amplitude:"ocean.amplitude",amplitudeVariance:"ocean.amplitudeVariance",speed:"ocean.speed",speedVariance:"ocean.speedVariance",color:"ocean.color",opacity:"ocean.opacity"}}),t.exports.Component=AFRAME.registerComponent("ocean",{schema:{width:{default:10,min:0},depth:{default:10,min:0},density:{default:10},amplitude:{default:.1},amplitudeVariance:{default:.3},speed:{default:1},speedVariance:{default:2},color:{default:"#7AD2F7",type:"color"},opacity:{default:.8}},play:function(){var e=this.el,t=this.data,i=e.components.material,n=new THREE.PlaneGeometry(t.width,t.depth,t.density,t.density);n.mergeVertices(),this.waves=[];for(var o,r=0,s=n.vertices.length;r<s;r++)o=n.vertices[r],this.waves.push({z:o.z,ang:Math.random()*Math.PI*2,amp:t.amplitude+Math.random()*t.amplitudeVariance,speed:(t.speed+Math.random()*t.speedVariance)/1e3});i||((i={}).material=new THREE.MeshPhongMaterial({color:t.color,transparent:t.opacity<1,opacity:t.opacity,shading:THREE.FlatShading})),this.mesh=new THREE.Mesh(n,i.material),e.setObject3D("mesh",this.mesh)},remove:function(){this.el.removeObject3D("mesh")},tick:function(e,t){if(t){for(var i,n,o=this.mesh.geometry.vertices,r=0;i=o[r];r++)n=this.waves[r],i.z=n.z+Math.sin(n.ang)*n.amp,n.ang+=n.speed*t;this.mesh.geometry.verticesNeedUpdate=!0}}})},{}],42:[function(e,t,i){"use strict";t.exports.Primitive=AFRAME.registerPrimitive("a-tube",{defaultComponents:{tube:{}},mappings:{path:"tube.path",segments:"tube.segments",radius:"tube.radius","radial-segments":"tube.radialSegments",closed:"tube.closed"}}),t.exports.Component=AFRAME.registerComponent("tube",{schema:{path:{default:[]},segments:{default:64},radius:{default:1},radialSegments:{default:8},closed:{default:!1}},init:function(){var e=this.el,t=this.data,i=e.components.material;if(t.path.length){var n=new THREE.CatmullRomCurve3(t.path.map(function(e){return e=e.split(" "),new THREE.Vector3(Number(e[0]),Number(e[1]),Number(e[2]))})),o=new THREE.TubeGeometry(n,t.segments,t.radius,t.radialSegments,t.closed);i||((i={}).material=new THREE.MeshPhongMaterial),this.mesh=new THREE.Mesh(o,i.material),this.el.setObject3D("mesh",this.mesh)}else console.error("[a-tube] `path` property expected but not found.")},update:function(e){Object.keys(e).length&&(this.remove(),this.init())},remove:function(){this.mesh&&this.el.removeObject3D("mesh")}})},{}],43:[function(e,t,i){"use strict";e("./a-grid"),e("./a-hexgrid"),e("./a-ocean"),e("./a-tube")},{"./a-grid":39,"./a-hexgrid":40,"./a-ocean":41,"./a-tube":42}]},{},[1]);
|