diff --git a/README.md b/README.md index 9f96562a..db19e01a 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@
-
+
- Play it here!
+ Launch in-browser demo
0){this.source.connect(this.filters[0]);for(var t=1,e=this.filters.length;t =0;t--)this.children[t].removeEmptyNodes(),this.children[t].children.length||this.children[t].data.length||this.children.splice(t,1)}},{"../collision/AABB":3,"../math/Vec3":31}],52:[function(t,e,n){function i(){this.objects=[],this.type=Object}e.exports=i,i.prototype.release=function(){for(var t=arguments.length,e=0;e!==t;e++)this.objects.push(arguments[e]);return this},i.prototype.get=function(){return 0===this.objects.length?this.constructObject():this.objects.pop()},i.prototype.constructObject=function(){throw new Error("constructObject() not implemented in this Pool subclass yet!")},i.prototype.resize=function(t){for(var e=this.objects;e.length>t;)e.pop();for(;e.length =0;t--)this.children[t].removeEmptyNodes(),this.children[t].children.length||this.children[t].data.length||this.children.splice(t,1)}},{"../collision/AABB":3,"../math/Vec3":31}],52:[function(t,e,n){function i(){this.objects=[],this.type=Object}e.exports=i,i.prototype.release=function(){for(var t=arguments.length,e=0;e!==t;e++)this.objects.push(arguments[e]);return this},i.prototype.get=function(){return 0===this.objects.length?this.constructObject():this.objects.pop()},i.prototype.constructObject=function(){throw new Error("constructObject() not implemented in this Pool subclass yet!")},i.prototype.resize=function(t){for(var e=this.objects;e.length>t;)e.pop();for(;e.lengthKp-Qp?i-Kp+Qp:0),3*y,2*y),ud.setRenderTarget(e),ud.render(s,nd)}function Md(){var t=new Ul({uniforms:{envMap:{value:null},texelSize:{value:new An(1,1)},inputEncoding:{value:ed[De]},outputEncoding:{value:ed[De]}},vertexShader:Ad(),fragmentShader:`\nprecision mediump float;\nprecision mediump int;\nvarying vec3 vOutputDirection;\nuniform sampler2D envMap;\nuniform vec2 texelSize;\n\n${Td()}\n\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n\nvoid main() {\n\tgl_FragColor = vec4(0.0);\n\tvec3 outputDirection = normalize(vOutputDirection);\n\tvec2 uv;\n\tuv.y = asin(clamp(outputDirection.y, -1.0, 1.0)) * RECIPROCAL_PI + 0.5;\n\tuv.x = atan(outputDirection.z, outputDirection.x) * RECIPROCAL_PI2 + 0.5;\n\tvec2 f = fract(uv / texelSize - 0.5);\n\tuv -= f * texelSize;\n\tvec3 tl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n\tuv.x += texelSize.x;\n\tvec3 tr = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n\tuv.y += texelSize.y;\n\tvec3 br = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n\tuv.x -= texelSize.x;\n\tvec3 bl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n\tvec3 tm = mix(tl, tr, f.x);\n\tvec3 bm = mix(bl, br, f.x);\n\tgl_FragColor.rgb = mix(tm, bm, f.y);\n\tgl_FragColor = linearToOutputTexel(gl_FragColor);\n}\n\t\t`,blending:M,depthTest:!1,depthWrite:!1});return t.type="EquirectangularToCubeUV",t}function Ed(){var t=new Ul({uniforms:{envMap:{value:null},inputEncoding:{value:ed[De]},outputEncoding:{value:ed[De]}},vertexShader:Ad(),fragmentShader:`\nprecision mediump float;\nprecision mediump int;\nvarying vec3 vOutputDirection;\nuniform samplerCube envMap;\n\n${Td()}\n\nvoid main() {\n\tgl_FragColor = vec4(0.0);\n\tgl_FragColor.rgb = envMapTexelToLinear(textureCube(envMap, vec3( - vOutputDirection.x, vOutputDirection.yz ))).rgb;\n\tgl_FragColor = linearToOutputTexel(gl_FragColor);\n}\n\t\t`,blending:M,depthTest:!1,depthWrite:!1});return t.type="CubemapToCubeUV",t}function Ad(){return"\nprecision mediump float;\nprecision mediump int;\nattribute vec3 position;\nattribute vec2 uv;\nattribute float faceIndex;\nvarying vec3 vOutputDirection;\nvec3 getDirection(vec2 uv, float face) {\n\tuv = 2.0 * uv - 1.0;\n\tvec3 direction = vec3(uv, 1.0);\n\tif (face == 0.0) {\n\t\tdirection = direction.zyx;\n\t\tdirection.z *= -1.0;\n\t} else if (face == 1.0) {\n\t\tdirection = direction.xzy;\n\t\tdirection.z *= -1.0;\n\t} else if (face == 3.0) {\n\t\tdirection = direction.zyx;\n\t\tdirection.x *= -1.0;\n\t} else if (face == 4.0) {\n\t\tdirection = direction.xzy;\n\t\tdirection.y *= -1.0;\n\t} else if (face == 5.0) {\n\t\tdirection.xz *= -1.0;\n\t}\n\treturn direction;\n}\nvoid main() {\n\tvOutputDirection = getDirection(uv, faceIndex);\n\tgl_Position = vec4( position, 1.0 );\n}\n\t"}function Td(){return"\nuniform int inputEncoding;\nuniform int outputEncoding;\n\n#include =l&&(s=l-1),c<0?c=0:c>=u&&(c=u-1),m<0?m=0:m>=h&&(m=h-1),v<0?v=0:v>=l&&(v=l-1),g<0?g=0:g>=u&&(g=u-1),M<0?M=0:M>=h&&(M=h-1),c*=d,m*=f,v*=p,g*=d,M*=f;for(var E=s*=p;E<=v;E+=p)for(var A=c;A<=g;A+=d)for(var T=m;T<=M;T+=f){var P=E+A+T;R[P][O[P]++]=a}}for(c=Math.min,a=Math.max,I=0;I!==i;I++){var D=(nt=r[I]).shape;switch(D.type){case L:var z=nt.position.x,V=nt.position.y,U=nt.position.z,k=D.radius;B(z-k,V-k,U-k,z+k,V+k,U+k,nt);break;case C:D.worldNormalNeedsUpdate&&D.computeWorldNormal(nt.quaternion);var j=D.worldNormal,H=y+.5*M-nt.position.x,G=w+.5*E-nt.position.y,W=x+.5*A-nt.position.z,q=s;q.set(H,G,W);for(var X=0,Y=0;X!==l;X++,Y+=p,q.y=G,q.x+=M)for(var Q=0,K=0;Q!==u;Q++,K+=d,q.z=W,q.y+=E)for(var Z=0,J=0;Z!==h;Z++,J+=f,q.z+=A)if(q.dot(j)m?f>v?0:2:m>v?1:2},r.prototype.aabbQuery=function(t,e,n){n=n||[],this.dirty&&(this.sortList(),this.dirty=!1);var i=this.axisIndex,r="x";1===i&&(r="y"),2===i&&(r="z");for(var o=this.axisList,a=(e.lowerBound[r],e.upperBound[r],0);ap.length||w>p[0].length)){g<0&&(g=0),y<0&&(y=0),w<0&&(w=0),x<0&&(x=0),g>=p.length&&(g=p.length-1),y>=p.length&&(y=p.length-1),x>=p[0].length&&(x=p[0].length-1),w>=p[0].length&&(w=p[0].length-1);var _=[];e.getRectMinMax(g,w,y,x,_);var b=_[0],S=_[1];if(!(v.z-d>S||v.z+d2)return}}}},{"../collision/AABB":3,"../collision/Ray":10,"../equations/ContactEquation":20,"../equations/FrictionEquation":22,"../math/Quaternion":29,"../math/Transform":30,"../math/Vec3":31,"../objects/Body":32,"../shapes/ConvexPolyhedron":39,"../shapes/Shape":44,"../solver/Solver":48,"../utils/Vec3Pool":55}],57:[function(t,e,n){e.exports=y,t("../shapes/Shape");var i=t("../math/Vec3"),r=t("../math/Quaternion"),o=t("../solver/GSSolver"),a=(t("../equations/ContactEquation"),t("../equations/FrictionEquation"),t("./Narrowphase")),s=t("../utils/EventTarget"),c=t("../collision/ArrayCollisionMatrix"),l=t("../collision/OverlapKeeper"),u=t("../material/Material"),h=t("../material/ContactMaterial"),p=t("../objects/Body"),d=t("../utils/TupleDictionary"),f=t("../collision/RaycastResult"),m=t("../collision/AABB"),v=t("../collision/Ray"),g=t("../collision/NaiveBroadphase");function y(t){t=t||{},s.apply(this),this.dt=-1,this.allowSleep=!!t.allowSleep,this.contacts=[],this.frictionEquations=[],this.quatNormalizeSkip=void 0!==t.quatNormalizeSkip?t.quatNormalizeSkip:0,this.quatNormalizeFast=void 0!==t.quatNormalizeFast&&t.quatNormalizeFast,this.time=0,this.interpolationFactor=0,this.stepnumber=0,this.default_dt=1/60,this.nextId=0,this.gravity=new i,t.gravity&&this.gravity.copy(t.gravity),this.broadphase=void 0!==t.broadphase?t.broadphase:new g,this.bodies=[],this.solver=void 0!==t.solver?t.solver:new o,this.constraints=[],this.narrowphase=new a(this),this.collisionMatrix=new c,this.collisionMatrixPrevious=new c,this.bodyOverlapKeeper=new l,this.shapeOverlapKeeper=new l,this.materials=[],this.contactmaterials=[],this.contactMaterialTable=new d,this.defaultMaterial=new u("default"),this.defaultContactMaterial=new h(this.defaultMaterial,this.defaultMaterial,{friction:.3,restitution:0}),this.doProfiling=!1,this.profile={solve:0,makeContactConstraints:0,broadphase:0,integrate:0,narrowphase:0},this.accumulator=0,this.subsystems=[],this.addBodyEvent={type:"addBody",body:null},this.removeBodyEvent={type:"removeBody",body:null},this.idToBodyMap={},this.broadphase.setWorld(this)}y.prototype=new s,new m;var w=new v;if(y.prototype.getContactMaterial=function(t,e){return this.contactMaterialTable.get(t.id,e.id)},y.prototype.numObjects=function(){return this.bodies.length},y.prototype.collisionMatrixTick=function(){var t=this.collisionMatrixPrevious;this.collisionMatrixPrevious=this.collisionMatrix,this.collisionMatrix=t,this.collisionMatrix.reset(),this.bodyOverlapKeeper.tick(),this.shapeOverlapKeeper.tick()},y.prototype.add=y.prototype.addBody=function(t){-1===this.bodies.indexOf(t)&&(t.index=this.bodies.length,this.bodies.push(t),t.world=this,t.initPosition.copy(t.position),t.initVelocity.copy(t.velocity),t.timeLastSleepy=this.time,t instanceof p&&(t.initAngularVelocity.copy(t.angularVelocity),t.initQuaternion.copy(t.quaternion)),this.collisionMatrix.setNumObjects(this.bodies.length),this.addBodyEvent.body=t,this.idToBodyMap[t.id]=t,this.dispatchEvent(this.addBodyEvent))},y.prototype.addConstraint=function(t){this.constraints.push(t)},y.prototype.removeConstraint=function(t){var e=this.constraints.indexOf(t);-1!==e&&this.constraints.splice(e,1)},y.prototype.rayTest=function(t,e,n){n instanceof f?this.raycastClosest(t,e,{skipBackfaces:!0},n):this.raycastAll(t,e,{skipBackfaces:!0},n)},y.prototype.raycastAll=function(t,e,n,i){return n.mode=v.ALL,n.from=t,n.to=e,n.callback=i,w.intersectWorld(this,n)},y.prototype.raycastAny=function(t,e,n,i){return n.mode=v.ANY,n.from=t,n.to=e,n.result=i,w.intersectWorld(this,n)},y.prototype.raycastClosest=function(t,e,n,i){return n.mode=v.CLOSEST,n.from=t,n.to=e,n.result=i,w.intersectWorld(this,n)},y.prototype.remove=function(t){t.world=null;var e=this.bodies.length-1,n=this.bodies,i=n.indexOf(t);if(-1!==i){n.splice(i,1);for(var r=0;r!==n.length;r++)n[r].index=r;this.collisionMatrix.setNumObjects(e),this.removeBodyEvent.body=t,delete this.idToBodyMap[t.id],this.dispatchEvent(this.removeBodyEvent)}},y.prototype.removeBody=y.prototype.remove,y.prototype.getBodyById=function(t){return this.idToBodyMap[t]},y.prototype.getShapeById=function(t){for(var e=this.bodies,n=0,i=e.length;n=t&&iKp-Qp?i-Kp+Qp:0),3*y,2*y),ud.setRenderTarget(e),ud.render(s,nd)}function Md(){var t=new Ul({uniforms:{envMap:{value:null},texelSize:{value:new An(1,1)},inputEncoding:{value:ed[De]},outputEncoding:{value:ed[De]}},vertexShader:Ad(),fragmentShader:`\nprecision mediump float;\nprecision mediump int;\nvarying vec3 vOutputDirection;\nuniform sampler2D envMap;\nuniform vec2 texelSize;\n\n${Td()}\n\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n\nvoid main() {\n\tgl_FragColor = vec4(0.0);\n\tvec3 outputDirection = normalize(vOutputDirection);\n\tvec2 uv;\n\tuv.y = asin(clamp(outputDirection.y, -1.0, 1.0)) * RECIPROCAL_PI + 0.5;\n\tuv.x = atan(outputDirection.z, outputDirection.x) * RECIPROCAL_PI2 + 0.5;\n\tvec2 f = fract(uv / texelSize - 0.5);\n\tuv -= f * texelSize;\n\tvec3 tl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n\tuv.x += texelSize.x;\n\tvec3 tr = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n\tuv.y += texelSize.y;\n\tvec3 br = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n\tuv.x -= texelSize.x;\n\tvec3 bl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n\tvec3 tm = mix(tl, tr, f.x);\n\tvec3 bm = mix(bl, br, f.x);\n\tgl_FragColor.rgb = mix(tm, bm, f.y);\n\tgl_FragColor = linearToOutputTexel(gl_FragColor);\n}\n\t\t`,blending:M,depthTest:!1,depthWrite:!1});return t.type="EquirectangularToCubeUV",t}function Ed(){var t=new Ul({uniforms:{envMap:{value:null},inputEncoding:{value:ed[De]},outputEncoding:{value:ed[De]}},vertexShader:Ad(),fragmentShader:`\nprecision mediump float;\nprecision mediump int;\nvarying vec3 vOutputDirection;\nuniform samplerCube envMap;\n\n${Td()}\n\nvoid main() {\n\tgl_FragColor = vec4(0.0);\n\tgl_FragColor.rgb = envMapTexelToLinear(textureCube(envMap, vec3( - vOutputDirection.x, vOutputDirection.yz ))).rgb;\n\tgl_FragColor = linearToOutputTexel(gl_FragColor);\n}\n\t\t`,blending:M,depthTest:!1,depthWrite:!1});return t.type="CubemapToCubeUV",t}function Ad(){return"\nprecision mediump float;\nprecision mediump int;\nattribute vec3 position;\nattribute vec2 uv;\nattribute float faceIndex;\nvarying vec3 vOutputDirection;\nvec3 getDirection(vec2 uv, float face) {\n\tuv = 2.0 * uv - 1.0;\n\tvec3 direction = vec3(uv, 1.0);\n\tif (face == 0.0) {\n\t\tdirection = direction.zyx;\n\t\tdirection.z *= -1.0;\n\t} else if (face == 1.0) {\n\t\tdirection = direction.xzy;\n\t\tdirection.z *= -1.0;\n\t} else if (face == 3.0) {\n\t\tdirection = direction.zyx;\n\t\tdirection.x *= -1.0;\n\t} else if (face == 4.0) {\n\t\tdirection = direction.xzy;\n\t\tdirection.y *= -1.0;\n\t} else if (face == 5.0) {\n\t\tdirection.xz *= -1.0;\n\t}\n\treturn direction;\n}\nvoid main() {\n\tvOutputDirection = getDirection(uv, faceIndex);\n\tgl_Position = vec4( position, 1.0 );\n}\n\t"}function Td(){return"\nuniform int inputEncoding;\nuniform int outputEncoding;\n\n#include =l&&(s=l-1),c<0?c=0:c>=u&&(c=u-1),m<0?m=0:m>=h&&(m=h-1),v<0?v=0:v>=l&&(v=l-1),g<0?g=0:g>=u&&(g=u-1),M<0?M=0:M>=h&&(M=h-1),c*=d,m*=f,v*=p,g*=d,M*=f;for(var E=s*=p;E<=v;E+=p)for(var A=c;A<=g;A+=d)for(var T=m;T<=M;T+=f){var P=E+A+T;R[P][O[P]++]=a}}for(c=Math.min,a=Math.max,I=0;I!==i;I++){var D=(nt=r[I]).shape;switch(D.type){case L:var z=nt.position.x,V=nt.position.y,U=nt.position.z,k=D.radius;B(z-k,V-k,U-k,z+k,V+k,U+k,nt);break;case C:D.worldNormalNeedsUpdate&&D.computeWorldNormal(nt.quaternion);var j=D.worldNormal,H=y+.5*M-nt.position.x,G=w+.5*E-nt.position.y,W=x+.5*A-nt.position.z,q=s;q.set(H,G,W);for(var X=0,Y=0;X!==l;X++,Y+=p,q.y=G,q.x+=M)for(var Q=0,K=0;Q!==u;Q++,K+=d,q.z=W,q.y+=E)for(var Z=0,J=0;Z!==h;Z++,J+=f,q.z+=A)if(q.dot(j)m?f>v?0:2:m>v?1:2},r.prototype.aabbQuery=function(t,e,n){n=n||[],this.dirty&&(this.sortList(),this.dirty=!1);var i=this.axisIndex,r="x";1===i&&(r="y"),2===i&&(r="z");for(var o=this.axisList,a=(e.lowerBound[r],e.upperBound[r],0);ap.length||w>p[0].length)){g<0&&(g=0),y<0&&(y=0),w<0&&(w=0),x<0&&(x=0),g>=p.length&&(g=p.length-1),y>=p.length&&(y=p.length-1),x>=p[0].length&&(x=p[0].length-1),w>=p[0].length&&(w=p[0].length-1);var _=[];e.getRectMinMax(g,w,y,x,_);var b=_[0],S=_[1];if(!(v.z-d>S||v.z+d2)return}}}},{"../collision/AABB":3,"../collision/Ray":10,"../equations/ContactEquation":20,"../equations/FrictionEquation":22,"../math/Quaternion":29,"../math/Transform":30,"../math/Vec3":31,"../objects/Body":32,"../shapes/ConvexPolyhedron":39,"../shapes/Shape":44,"../solver/Solver":48,"../utils/Vec3Pool":55}],57:[function(t,e,n){e.exports=y,t("../shapes/Shape");var i=t("../math/Vec3"),r=t("../math/Quaternion"),o=t("../solver/GSSolver"),a=(t("../equations/ContactEquation"),t("../equations/FrictionEquation"),t("./Narrowphase")),s=t("../utils/EventTarget"),c=t("../collision/ArrayCollisionMatrix"),l=t("../collision/OverlapKeeper"),u=t("../material/Material"),h=t("../material/ContactMaterial"),p=t("../objects/Body"),d=t("../utils/TupleDictionary"),f=t("../collision/RaycastResult"),m=t("../collision/AABB"),v=t("../collision/Ray"),g=t("../collision/NaiveBroadphase");function y(t){t=t||{},s.apply(this),this.dt=-1,this.allowSleep=!!t.allowSleep,this.contacts=[],this.frictionEquations=[],this.quatNormalizeSkip=void 0!==t.quatNormalizeSkip?t.quatNormalizeSkip:0,this.quatNormalizeFast=void 0!==t.quatNormalizeFast&&t.quatNormalizeFast,this.time=0,this.interpolationFactor=0,this.stepnumber=0,this.default_dt=1/60,this.nextId=0,this.gravity=new i,t.gravity&&this.gravity.copy(t.gravity),this.broadphase=void 0!==t.broadphase?t.broadphase:new g,this.bodies=[],this.solver=void 0!==t.solver?t.solver:new o,this.constraints=[],this.narrowphase=new a(this),this.collisionMatrix=new c,this.collisionMatrixPrevious=new c,this.bodyOverlapKeeper=new l,this.shapeOverlapKeeper=new l,this.materials=[],this.contactmaterials=[],this.contactMaterialTable=new d,this.defaultMaterial=new u("default"),this.defaultContactMaterial=new h(this.defaultMaterial,this.defaultMaterial,{friction:.3,restitution:0}),this.doProfiling=!1,this.profile={solve:0,makeContactConstraints:0,broadphase:0,integrate:0,narrowphase:0},this.accumulator=0,this.subsystems=[],this.addBodyEvent={type:"addBody",body:null},this.removeBodyEvent={type:"removeBody",body:null},this.idToBodyMap={},this.broadphase.setWorld(this)}y.prototype=new s,new m;var w=new v;if(y.prototype.getContactMaterial=function(t,e){return this.contactMaterialTable.get(t.id,e.id)},y.prototype.numObjects=function(){return this.bodies.length},y.prototype.collisionMatrixTick=function(){var t=this.collisionMatrixPrevious;this.collisionMatrixPrevious=this.collisionMatrix,this.collisionMatrix=t,this.collisionMatrix.reset(),this.bodyOverlapKeeper.tick(),this.shapeOverlapKeeper.tick()},y.prototype.add=y.prototype.addBody=function(t){-1===this.bodies.indexOf(t)&&(t.index=this.bodies.length,this.bodies.push(t),t.world=this,t.initPosition.copy(t.position),t.initVelocity.copy(t.velocity),t.timeLastSleepy=this.time,t instanceof p&&(t.initAngularVelocity.copy(t.angularVelocity),t.initQuaternion.copy(t.quaternion)),this.collisionMatrix.setNumObjects(this.bodies.length),this.addBodyEvent.body=t,this.idToBodyMap[t.id]=t,this.dispatchEvent(this.addBodyEvent))},y.prototype.addConstraint=function(t){this.constraints.push(t)},y.prototype.removeConstraint=function(t){var e=this.constraints.indexOf(t);-1!==e&&this.constraints.splice(e,1)},y.prototype.rayTest=function(t,e,n){n instanceof f?this.raycastClosest(t,e,{skipBackfaces:!0},n):this.raycastAll(t,e,{skipBackfaces:!0},n)},y.prototype.raycastAll=function(t,e,n,i){return n.mode=v.ALL,n.from=t,n.to=e,n.callback=i,w.intersectWorld(this,n)},y.prototype.raycastAny=function(t,e,n,i){return n.mode=v.ANY,n.from=t,n.to=e,n.result=i,w.intersectWorld(this,n)},y.prototype.raycastClosest=function(t,e,n,i){return n.mode=v.CLOSEST,n.from=t,n.to=e,n.result=i,w.intersectWorld(this,n)},y.prototype.remove=function(t){t.world=null;var e=this.bodies.length-1,n=this.bodies,i=n.indexOf(t);if(-1!==i){n.splice(i,1);for(var r=0;r!==n.length;r++)n[r].index=r;this.collisionMatrix.setNumObjects(e),this.removeBodyEvent.body=t,delete this.idToBodyMap[t.id],this.dispatchEvent(this.removeBodyEvent)}},y.prototype.removeBody=y.prototype.remove,y.prototype.getBodyById=function(t){return this.idToBodyMap[t]},y.prototype.getShapeById=function(t){for(var e=this.bodies,n=0,i=e.length;n=t&&i\n \n \n \n \n \n \n \n \n
','Find out how to get it here.'].join("\n"):['Your browser does not seem to support WebGL.
','Find out how to get it here.'].join("\n")),t},addGetWebGLMessage:function(t){var e,n,r;e=void 0!==(t=t||{}).parent?t.parent:document.body,n=void 0!==t.id?t.id:"oldie",(r=i.getWebGLErrorMessage()).id=n,e.appendChild(r)}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=function(){function t(){}return t.setUserInterfaceVisible=function(t){document.getElementById("ui-container").style.display=t?"block":"none"},t.setLoadingScreenVisible=function(t){document.getElementById("loading-screen").style.display=t?"flex":"none"},t.setFPSVisible=function(t){document.getElementById("statsBox").style.display=t?"block":"none",document.getElementById("dat-gui-container").style.top=t?"48px":"0px"},t}();e.UIManager=i},function(t,e,n){"use strict";var i,r=this&&this.__extends||(i=function(t,e){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var o=n(0),a=n(3),s=n(5),c=n(9),l=n(11),u=n(17),h=n(2),p=n(21),d=function(t){function e(e,n,i){var r=t.call(this,e)||this;r.startPosition=new o.Vector3,r.endPosition=new o.Vector3,r.startRotation=new o.Quaternion,r.endRotation=new o.Quaternion,r.toSeat=i,r.canFindVehiclesToEnter=!1,r.canLeaveVehicles=!1,e.leaveSeat(),r.character.occupySeat(i);var a=h.getRight(n.seatPointObject,p.Space.Local),c=i.seatPointObject.position.clone().sub(n.seatPointObject.position).normalize(),l=a.dot(c)>0?s.Side.Left:s.Side.Right;return l===s.Side.Left?r.playAnimation("sitting_shift_left",.1):l===s.Side.Right&&r.playAnimation("sitting_shift_right",.1),r.startPosition.copy(n.seatPointObject.position),r.startPosition.y+=.6,r.endPosition.copy(i.seatPointObject.position),r.endPosition.y+=.6,r.startRotation.copy(n.seatPointObject.quaternion),r.endRotation.copy(i.seatPointObject.quaternion),r}return r(e,t),e.prototype.update=function(e){if(t.prototype.update.call(this,e),this.animationEnded(e))this.toSeat.type===c.SeatType.Driver?this.character.setState(new l.Driving(this.character,this.toSeat)):this.toSeat.type===c.SeatType.Passenger&&this.character.setState(new u.Sitting(this.character,this.toSeat));else{var n=this.timer/this.animationLength,i=h.easeInOutSine(n),r=(new o.Vector3).lerpVectors(this.startPosition,this.endPosition,i);this.character.setPosition(r.x,r.y,r.z),o.Quaternion.slerp(this.startRotation,this.endRotation,this.character.quaternion,i)}},e}(a.CharacterStateBase);e.SwitchingSeats=d},function(t,e,n){"use strict";var i,r=this&&this.__extends||(i=function(t,e){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var o=n(3),a=function(t){function e(e){var n=t.call(this,e)||this;return n.character.velocitySimulator.mass=1,n.character.velocitySimulator.damping=.6,n.character.setArcadeVelocityTarget(.8),n.playAnimation("drop_running_roll",.03),n}return r(e,t),e.prototype.update=function(e){t.prototype.update.call(this,e),this.character.setCameraRelativeOrientationTarget(),this.animationEnded(e)&&(this.anyDirection()?this.character.setState(new o.Walk(this.character)):this.character.setState(new o.EndWalk(this.character)))},e}(o.CharacterStateBase);e.DropRolling=a},function(t,e,n){"use strict";var i,r=this&&this.__extends||(i=function(t,e){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var o=n(3),a=n(5),s=n(11),c=n(9),l=n(17),u=n(2),h=function(t){function e(e,n){var i,r=t.call(this,e)||this;r.hasClosedDoor=!1,r.seat=n,r.canFindVehiclesToEnter=!1,r.canLeaveVehicles=!1;var o=u.detectRelativeSide(n.seatPointObject,n.door.doorObject);return o===a.Side.Left?r.playAnimation("close_door_sitting_left",.1):o===a.Side.Right&&r.playAnimation("close_door_sitting_right",.1),null===(i=r.seat.door)||void 0===i||i.open(),r}return r(e,t),e.prototype.update=function(e){var n;t.prototype.update.call(this,e),this.timer>.4&&!this.hasClosedDoor&&(this.hasClosedDoor=!0,null===(n=this.seat.door)||void 0===n||n.close()),this.animationEnded(e)&&(this.seat.type===c.SeatType.Driver?this.character.setState(new s.Driving(this.character,this.seat)):this.seat.type===c.SeatType.Passenger&&this.character.setState(new l.Sitting(this.character,this.seat)))},e}(o.CharacterStateBase);e.CloseVehicleDoorInside=h},function(t,e,n){"use strict";var i,r=this&&this.__extends||(i=function(t,e){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var o=n(0),a=n(1),s=n(6),c=n(2),l=n(7),u=n(79),h=n(81),p=n(8),d=n(28),f=n(82),m=n(84),v=n(11),g=n(85),y=n(14),w=n(86),x=n(87),_=n(9),b=n(88),S=n(89),M=n(10),E=function(t){function e(e){var n=t.call(this)||this;n.updateOrder=1,n.entityType=M.EntityType.Character,n.height=0,n.materials=[],n.acceleration=new o.Vector3,n.velocity=new o.Vector3,n.arcadeVelocityInfluence=new o.Vector3,n.velocityTarget=new o.Vector3,n.arcadeVelocityIsAdditive=!1,n.defaultVelocitySimulatorDamping=.8,n.defaultVelocitySimulatorMass=50,n.moveSpeed=4,n.angularVelocity=0,n.orientation=new o.Vector3(0,0,1),n.orientationTarget=new o.Vector3(0,0,1),n.defaultRotationSimulatorDamping=.5,n.defaultRotationSimulatorMass=10,n.rayResult=new a.RaycastResult,n.rayHasHit=!1,n.rayCastLength=.57,n.raySafeOffset=.03,n.wantsToJump=!1,n.initJumpSpeed=-1,n.groundImpactData=new b.GroundImpactData,n.occupyingSeat=null,n.vehicleEntryInstance=null,n.physicsEnabled=!0,n.readCharacterData(e),n.setAnimations(e.animations),n.tiltContainer=new o.Group,n.add(n.tiltContainer),n.modelContainer=new o.Group,n.modelContainer.position.y=-.57,n.tiltContainer.add(n.modelContainer),n.modelContainer.add(e.scene),n.mixer=new o.AnimationMixer(e.scene),n.velocitySimulator=new u.VectorSpringSimulator(60,n.defaultVelocitySimulatorMass,n.defaultVelocitySimulatorDamping),n.rotationSimulator=new h.RelativeSpringSimulator(60,n.defaultRotationSimulatorMass,n.defaultRotationSimulatorDamping),n.viewVector=new o.Vector3,n.actions={up:new l.KeyBinding("KeyW"),down:new l.KeyBinding("KeyS"),left:new l.KeyBinding("KeyA"),right:new l.KeyBinding("KeyD"),run:new l.KeyBinding("ShiftLeft"),jump:new l.KeyBinding("Space"),use:new l.KeyBinding("KeyE"),enter:new l.KeyBinding("KeyF"),enter_passenger:new l.KeyBinding("KeyG"),seat_switch:new l.KeyBinding("KeyX"),primary:new l.KeyBinding("Mouse0"),secondary:new l.KeyBinding("Mouse1")},n.characterCapsule=new w.CapsuleCollider({mass:1,position:new a.Vec3,height:.5,radius:.25,segments:8,friction:0}),n.characterCapsule.body.shapes.forEach((function(t){t.collisionFilterMask=~y.CollisionGroups.TrimeshColliders})),n.characterCapsule.body.allowSleep=!1,n.characterCapsule.body.collisionFilterGroup=2,n.characterCapsule.body.fixedRotation=!0,n.characterCapsule.body.updateMassProperties();var i=new o.BoxGeometry(.1,.1,.1),r=new o.MeshLambertMaterial({color:16711680});return n.raycastBox=new o.Mesh(i,r),n.raycastBox.visible=!1,n.characterCapsule.body.preStep=function(t){n.physicsPreStep(t,n)},n.characterCapsule.body.postStep=function(t){n.physicsPostStep(t,n)},n.setState(new p.Idle(n)),n}return r(e,t),e.prototype.setAnimations=function(t){this.animations=t},e.prototype.setArcadeVelocityInfluence=function(t,e,n){void 0===e&&(e=t),void 0===n&&(n=t),this.arcadeVelocityInfluence.set(t,e,n)},e.prototype.setViewVector=function(t){this.viewVector.copy(t).normalize()},e.prototype.setState=function(t){this.charState=t,this.charState.onInputChange()},e.prototype.setPosition=function(t,e,n){this.physicsEnabled?(this.characterCapsule.body.previousPosition=new a.Vec3(t,e,n),this.characterCapsule.body.position=new a.Vec3(t,e,n),this.characterCapsule.body.interpolatedPosition=new a.Vec3(t,e,n)):(this.position.x=t,this.position.y=e,this.position.z=n)},e.prototype.resetVelocity=function(){this.velocity.x=0,this.velocity.y=0,this.velocity.z=0,this.characterCapsule.body.velocity.x=0,this.characterCapsule.body.velocity.y=0,this.characterCapsule.body.velocity.z=0,this.velocitySimulator.init()},e.prototype.setArcadeVelocityTarget=function(t,e,n){void 0===e&&(e=0),void 0===n&&(n=0),this.velocityTarget.z=t,this.velocityTarget.x=e,this.velocityTarget.y=n},e.prototype.setOrientation=function(t,e){void 0===e&&(e=!1);var n=(new o.Vector3).copy(t).setY(0).normalize();this.orientationTarget.copy(n),e&&this.orientation.copy(n)},e.prototype.resetOrientation=function(){var t=c.getForward(this);this.setOrientation(t,!0)},e.prototype.setBehaviour=function(t){t.character=this,this.behaviour=t},e.prototype.setPhysicsEnabled=function(t){this.physicsEnabled=t,!0===t?this.world.physicsWorld.addBody(this.characterCapsule.body):this.world.physicsWorld.remove(this.characterCapsule.body)},e.prototype.readCharacterData=function(t){var e=this;t.scene.traverse((function(t){t.isMesh&&(c.setupMeshProperties(t),void 0!==t.material&&e.materials.push(t.material))}))},e.prototype.handleKeyboardEvent=function(t,e,n){if(void 0!==this.controlledObject)this.controlledObject.handleKeyboardEvent(t,e,n);else if("KeyC"===e&&!0===n&&!0===t.shiftKey)this.resetControls(),this.world.cameraOperator.characterCaller=this,this.world.inputManager.setInputReceiver(this.world.cameraOperator);else if("KeyR"===e&&!0===n&&!0===t.shiftKey)this.world.restartScenario();else for(var i in this.actions)if(this.actions.hasOwnProperty(i)){var r=this.actions[i];s.includes(r.eventCodes,e)&&this.triggerAction(i,n)}},e.prototype.handleMouseButton=function(t,e,n){if(void 0!==this.controlledObject)this.controlledObject.handleMouseButton(t,e,n);else for(var i in this.actions)if(this.actions.hasOwnProperty(i)){var r=this.actions[i];s.includes(r.eventCodes,e)&&this.triggerAction(i,n)}},e.prototype.handleMouseMove=function(t,e,n){void 0!==this.controlledObject?this.controlledObject.handleMouseMove(t,e,n):this.world.cameraOperator.move(e,n)},e.prototype.handleMouseWheel=function(t,e){void 0!==this.controlledObject?this.controlledObject.handleMouseWheel(t,e):this.world.scrollTheTimeScale(e)},e.prototype.triggerAction=function(t,e){var n=this.actions[t];n.isPressed!==e&&(n.isPressed=e,n.justPressed=!1,n.justReleased=!1,e?n.justPressed=!0:n.justReleased=!0,this.charState.onInputChange(),n.justPressed=!1,n.justReleased=!1)},e.prototype.takeControl=function(){void 0!==this.world?this.world.inputManager.setInputReceiver(this):console.warn("Attempting to take control of a character that doesn't belong to a world.")},e.prototype.resetControls=function(){for(var t in this.actions)this.actions.hasOwnProperty(t)&&this.triggerAction(t,!1)},e.prototype.update=function(t){var e,n,i;if(null===(e=this.behaviour)||void 0===e||e.update(t),null===(n=this.vehicleEntryInstance)||void 0===n||n.update(t),null===(i=this.charState)||void 0===i||i.update(t),this.physicsEnabled&&this.springMovement(t),this.physicsEnabled&&this.springRotation(t),this.physicsEnabled&&this.rotateModel(),void 0!==this.mixer&&this.mixer.update(t),this.physicsEnabled)this.position.set(this.characterCapsule.body.interpolatedPosition.x,this.characterCapsule.body.interpolatedPosition.y,this.characterCapsule.body.interpolatedPosition.z);else{var r=new o.Vector3;this.getWorldPosition(r),this.characterCapsule.body.position.copy(c.cannonVector(r)),this.characterCapsule.body.interpolatedPosition.copy(c.cannonVector(r))}this.updateMatrixWorld()},e.prototype.inputReceiverInit=function(){void 0===this.controlledObject?(this.world.cameraOperator.setRadius(1.6,!0),this.world.cameraOperator.followMode=!1,this.displayControls()):this.controlledObject.inputReceiverInit()},e.prototype.displayControls=function(){this.world.updateControls([{keys:["W","A","S","D"],desc:"Movement"},{keys:["Shift"],desc:"Sprint"},{keys:["Space"],desc:"Jump"},{keys:["F","or","G"],desc:"Enter vehicle"},{keys:["Shift","+","R"],desc:"Respawn"},{keys:["Shift","+","C"],desc:"Free camera"}])},e.prototype.inputReceiverUpdate=function(t){void 0!==this.controlledObject?this.controlledObject.inputReceiverUpdate(t):(this.viewVector=(new o.Vector3).subVectors(this.position,this.world.camera.position),this.getWorldPosition(this.world.cameraOperator.target))},e.prototype.setAnimation=function(t,e){if(void 0!==this.mixer){var n=o.AnimationClip.findByName(this.animations,t),i=this.mixer.clipAction(n);return null===i?(console.error("Animation "+t+" not found!"),0):(this.mixer.stopAllAction(),i.fadeIn(e),i.play(),i.getClip().duration)}},e.prototype.springMovement=function(t){this.velocitySimulator.target.copy(this.velocityTarget),this.velocitySimulator.simulate(t),this.velocity.copy(this.velocitySimulator.position),this.acceleration.copy(this.velocitySimulator.velocity)},e.prototype.springRotation=function(t){var e=c.getSignedAngleBetweenVectors(this.orientation,this.orientationTarget);this.rotationSimulator.target=e,this.rotationSimulator.simulate(t);var n=this.rotationSimulator.position;this.orientation.applyAxisAngle(new o.Vector3(0,1,0),n),this.angularVelocity=this.rotationSimulator.velocity},e.prototype.getLocalMovementDirection=function(){var t=this.actions.right.isPressed?-1:0,e=this.actions.left.isPressed?1:0,n=this.actions.up.isPressed?1:0,i=this.actions.down.isPressed?-1:0;return new o.Vector3(t+e,0,n+i).normalize()},e.prototype.getCameraRelativeMovementVector=function(){var t=this.getLocalMovementDirection(),e=new o.Vector3(this.viewVector.x,0,this.viewVector.z).normalize();return c.appplyVectorMatrixXZ(e,t)},e.prototype.setCameraRelativeOrientationTarget=function(){if(null===this.vehicleEntryInstance){var t=this.getCameraRelativeMovementVector();0===t.x&&0===t.y&&0===t.z?this.setOrientation(this.orientation):this.setOrientation(t)}},e.prototype.rotateModel=function(){this.lookAt(this.position.x+this.orientation.x,this.position.y+this.orientation.y,this.position.z+this.orientation.z),this.tiltContainer.rotation.z=2.3*-this.angularVelocity*this.velocity.length(),this.tiltContainer.position.setY(Math.cos(Math.abs(2.3*this.angularVelocity*this.velocity.length()))/2-.5)},e.prototype.jump=function(t){void 0===t&&(t=-1),this.wantsToJump=!0,this.initJumpSpeed=t},e.prototype.findVehicleToEnter=function(t){var e=new o.Vector3,n=new S.ClosestObjectFinder(this.position,10);if(this.world.vehicles.forEach((function(t){n.consider(t,t.position)})),void 0!==n.closestObject){var i=n.closestObject,r=new x.VehicleEntryInstance(this);r.wantsToDrive=t;for(var a=new S.ClosestObjectFinder(this.position),s=0,c=i.seats;sControls:
',t.forEach((function(t){e+='GUI
\'s constructor:\n\n \n\n localStorage
on exit.\n\n localStorage
will\n override those passed to dat.GUI
\'s constructor. This makes it\n easier to work incrementally, but localStorage
is fragile,\n and your friends may not see the same values you do.\n\n