From e84d51b1d59287386ded48f40a7c66a6505af880 Mon Sep 17 00:00:00 2001 From: tailuge Date: Mon, 25 Nov 2024 19:45:33 +0000 Subject: [PATCH] tidy up readme --- README.md | 74 +++++++++++++++++-- dist/diagram.js | 2 +- dist/diagrams/forreadme.md | 32 +++----- dist/index.js | 2 +- dist/mathaven.js | 2 +- .../physics/claude => diagram}/constants.ts | 0 .../claude => diagram}/historymathaven.ts | 2 +- src/diagram/impulseplot.ts | 4 +- src/diagram/reboundplot.ts | 4 +- src/diagram/throwplot.ts | 2 +- src/mathaven.ts | 2 +- .../physics/{claude/qwen.ts => mathaven.ts} | 2 +- src/model/physics/physics.ts | 4 +- 13 files changed, 93 insertions(+), 39 deletions(-) rename src/{model/physics/claude => diagram}/constants.ts (100%) rename src/{model/physics/claude => diagram}/historymathaven.ts (87%) rename src/model/physics/{claude/qwen.ts => mathaven.ts} (98%) diff --git a/README.md b/README.md index 2cc86809..81f9b1e8 100644 --- a/README.md +++ b/README.md @@ -75,17 +75,79 @@ where #### cushion bounce - +This is based on a paper by [Mathaven](https://billiards.colostate.edu/physics_articles/Mathavan_IMechE_2010.pdf). Many of the [figures](https://tailuge.github.io/billiards/dist/diagrams/mathaven.html) from the paper are recreated to confirm correctness. - +Slip velocity at cushion contact point I - +$$ +ẋ_I = \dot{v_x} + \dot{\omega_y} R \sin \theta - \dot{\omega_z} R \cos \theta, +ẏ'_I = -\dot{v_y} \sin \theta + \dot{\omega_x} R +$$ - +$$ +\phi = \arctan\left(\frac{ẏ'_I}{ẋ_I}\right), +s = \sqrt{(ẋ_I)^2 + (ẏ'_I)^2} +$$ - +Slip velocity at table contact point C -Future [work](https://tailuge.github.io/billiards/dist/diagrams/mathaven.html) on [Mathaven](dist/diagrams/mathaven.md) cushion paper. +$$ +ẋ_C = \dot{v_x} - \dot{\omega_y} R, +ẏ_C = \dot{v_y} + \dot{\omega_x} R +$$ + +$$ +\phi' = \arctan\left(\frac{ẏ'_I}{ẋ_I}\right), +s' = \sqrt{(ẋ_C)^2 + (ẏ_C)^2} +$$ + +Numerical solutions for the centroid velocity of the ball during compression and resititution phases. + +$$ +(\dot{v_x})_{n+1} - (\dot{v_x})_n = - \frac{1}{M} \left[\mu_w \cos(\phi) + \mu_s \cos(\phi') \cdot (\sin \theta + \mu_w \sin(\phi) \cos \theta)\right] \Delta P_I +$$ + +$$ +(\dot{v_y})_{n+1} - (\dot{v_y})_n = - \frac{1}{M} \left[ \cos \theta - \mu_w \sin \theta \sin \phi + \mu_s \sin \phi' \cdot \left( \sin \theta + \mu_w \sin \phi \cos \theta \right) \right] \Delta P_I +$$ + +Numerical solutions for angular velocity of ball + +$$ +(\dot{\omega_x})_{n+1}−(\dot{\omega_x})_n = -\frac{5}{2MR}[\mu_w \sin(\phi) + \mu_s \sin(\phi') \times (\sin(\theta) + \mu_w \sin(\phi)\cos(\theta))]\Delta P_I +$$ + + +$$ +(\dot{\omega_y})_{n+1}−(\dot{\omega_y})_n = -\frac{5}{2MR}[\mu_w \cos(\phi)\sin(\theta) - \mu_s \cos(\phi') \times (\sin(\theta) + \mu_w \sin(\phi)\cos(\theta))]\Delta P_I +$$ + + +$$ +(\dot{\omega_z})_{n+1}−(\dot{\omega_z})_n = \frac{5}{2MR}(\mu_w \cos(\phi)\cos(\theta))\Delta P_I +$$ + +$`\theta`$ is a constant of the angle of cushion contact above ball centre with $`\sin(\theta) = 2/5`$. $`μ_s`$ is the coefficient of sliding friction between the ball and table surface. $`μ_w`$ is the coefficient of sliding friction between the ball and the cushion. + +Work done by the normal force at contact point $I$ along the $Z'$-axis which is aligned from the ball centre to I + +$$ +W_{Z'}^I(P_I^{(n+1)}) = W_{Z'}^I(P_I^{(n)}) + \frac{\Delta P_I}{2} \left( z'_I(P_I^{(n+1)}) + z'_I(P_I^{(n)}) \right) +$$ + +The ball is assumed to be bouncing in the +y cushion. Compression phase iterates until + +$$ +\dot{v_y} <= 0 +$$ + +For the restitution phase the iteration continues until the work done is + +$$ +W_{Z'}^I >= (1 - e_e^2) W_{compression} +$$ + +Some of the Mathaven equations not supplied by the paper were inferred by LLMs and the [code](./src/model/physics/mathaven.ts) for them was initially generated by a combination of [Claude, Qwen and GPT-4o](./dist/diagrams/mathaven.md). ## Useful commands diff --git a/dist/diagram.js b/dist/diagram.js index 6754c43a..e151254d 100644 --- a/dist/diagram.js +++ b/dist/diagram.js @@ -1 +1 @@ -"use strict";(self.webpackChunkbilliards=self.webpackChunkbilliards||[]).push([[338],{"./src/container/container.ts":(e,t,n)=>{n.d(t,{m:()=>J});var r=n("./src/events/stationaryevent.ts"),i=n("./node_modules/three/build/three.module.js"),s=n("./src/utils/utils.ts"),o=n("./src/view/cameratop.ts"),a=n("./src/model/physics/constants.ts");function l(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var c=/*#__PURE__*/function(){var e;function t(e){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),l(this,"camera",void 0),l(this,"mode",this.topView),l(this,"mainMode",this.aimView),l(this,"height",8*a.R),l(this,"elapsed",void 0),this.camera=new i.ubm(45,e,a.R,1e3*a.R)}return e=[{key:"update",value:function(e,t){this.elapsed=e,this.mode(t)}},{key:"topView",value:function(e){this.camera.fov=o.v.fov,this.camera.position.lerp(o.v.viewPoint(this.camera.aspect,this.camera.fov),.9),this.camera.up=s.up,this.camera.lookAt(s.v_)}},{key:"aimView",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.08,n=this.height,r=this.camera.aspect<.8;if(this.camera.fov=r?60:40,n<10*a.R){var i=100*(10*a.R-n);this.camera.fov-=i*(r?3:1)}this.camera.position.lerp(e.pos.clone().addScaledVector((0,s.Dz)(e.angle),-(18*a.R)),t),this.camera.position.z=n,this.camera.up=s.up,this.camera.lookAt(e.pos.clone().addScaledVector(s.up,n/2))}},{key:"adjustHeight",value:function(e){e=this.height<10*a.R?e/8:e,this.height=i.cj9.clamp(this.height+e,6*a.R,120*a.R),this.height>110*a.R&&this.suggestMode(this.topView),this.height<105*a.R&&this.suggestMode(this.aimView)}},{key:"suggestMode",value:function(e){this.mainMode===this.aimView&&(this.mode=e)}},{key:"forceMode",value:function(e){this.mode=e,this.mainMode=e}},{key:"forceMove",value:function(e){this.mode===this.aimView&&this.aimView(e,1)}},{key:"toggleMode",value:function(){this.mode===this.topView?this.mode=this.aimView:this.mode=this.topView,this.mainMode=this.mode}}],function(e,t){for(var n=0;n0&&(null===(t=this.cuePowerElement)||void 0===t?void 0:t.value)&&(this.cuePowerElement.value=e)}}],function(e,t){for(var n=0;nthis.sentTime+this.period||e.type!==N.B.AIM){this.flush(),this.apply(e),this.sentTime=performance.now();return}this.pending=e}}],function(e,t){for(var n=0;n0&&"RERACK"===this.shots[e].type&&e--,e}},{key:"lastShot",value:function(){var e=this.last();return this.state(this.states[e],[this.shots[e]])}},{key:"currentBreak",value:function(){if(void 0!==this.breakStart)return this.state(this.states[this.breakStart],this.shots.slice(this.breakStart),this.breakStartTime,this.container.rules.previousBreak)}},{key:"state",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];return{init:e,shots:t,start:n,now:Date.now(),score:r,wholeGame:i}}},{key:"updateBreak",value:function(e){var t=this.container.rules.isPartOfBreak(e),n=this.container.rules.isEndOfGame(e),r=D.P.potCount(e);if(t||this.breakLink(n),this.lastShotLink(t||n,r,D.P.pots(e)),n&&this.breakLink(n),!t){this.breakStart=void 0;return}void 0===this.breakStart&&(this.breakStart=this.last(),this.breakStartTime=Date.now())}},{key:"lastShotLink",value:function(e,t,n){var r="#000000";n.length>0&&n.forEach(function(e){r="#"+e.ballmesh.color.getHexString()});var i="⚈".repeat(t>1?t-1:0)+(e?"⚈":"⚆"),s=JSON.stringify(this.lastShot());this.generateLink(i,s,r)}},{key:"breakLink",value:function(e){var t=this.currentBreak();if(t&&(e||t.shots.pop(),1!==t.shots.length)){var n=0===this.container.rules.currentBreak?this.container.rules.previousBreak:this.container.rules.currentBreak;t.score=n;var r=JSON.stringify(t),i=z.A.crush(r);this.generateLink("break(".concat(n,")"),i,"black"),n>=4&&this.generateHiScoreLink(i)}}},{key:"wholeGameLink",value:function(){var e=this.wholeGame(),t="frame(".concat(this.shotCount(e.shots)," shots)"),n=JSON.stringify(e),r=z.A.crush(n);this.generateLink(t,r,"black")}},{key:"shotCount",value:function(e){return e.filter(function(e){return"RERACK"!==e.type}).length}},{key:"generateLink",value:function(e,t,n){var r="".concat(this.replayUrl).concat(this.fullyEncodeURI(t)),i='').concat(e,"");this.container.eventQueue.push(new L.b(null,"".concat(i)))}},{key:"generateHiScoreLink",value:function(e){var t="".concat(this.hiScoreUrl,"?ruletype=").concat(this.container.rules.rulename,"&state=").concat(this.fullyEncodeURI(e)),n='').concat("hi score 🏆","");this.container.eventQueue.push(new L.b(null,"".concat(n)))}},{key:"fullyEncodeURI",value:function(e){return encodeURIComponent(e).replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/\!/g,"%21").replace(/\*/g,"%2A")}}],function(e,t){for(var n=0;n').concat(e,"")));r.push(new L.b(null,o))})},this.redo.onclick=function(e){var r=new X.W(t.init,t.shots);r.retry=!0,n.interuptEventQueue(r)},this.replay.onclick=function(e){n.interuptEventQueue(t)}}}},{key:"interuptEventQueue",value:function(e){this.container.table.halt();var t=this.container.eventQueue;t.length=0,t.push(new r.T),t.push(e)}},{key:"getElement",value:function(e){return document.getElementById(e)}}],function(e,t){for(var n=0;n0?this.element.innerHTML="Break
"+e:this.element.innerHTML="")}},{key:"getElement",value:function(e){return document.getElementById(e)}}],function(e,t){for(var n=0;n0;){this.lastEventTime=this.last;var t=this.inputQueue.shift();t&&this.updateController(this.controller.handleInput(t))}if(this.table.allStationary()){var n=this.eventQueue.shift();n&&(this.lastEventTime=performance.now(),this.updateController(n.applyToController(this.controller)))}}},{key:"animate",value:function(e){var t=this;this.advance((e-this.last)/1e3),this.last=e,this.processEvents(),(e{n.d(t,{m:()=>u});var r=n("./src/controller/controller.ts"),i=n("./src/controller/controllerbase.ts"),s=n("./src/controller/playshot.ts"),o=n("./src/controller/replay.ts");function a(e){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function l(e,t){return(l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(c=function(){return!!e})()}var u=/*#__PURE__*/function(e){var t;function n(e){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,n),r=n,i=[e],r=a(r);var t,r,i,s,o=(s=(t=c()?Reflect.construct(r,i||[],a(this).constructor):r.apply(this,i))&&("object"==(t&&"undefined"!=typeof Symbol&&t.constructor===Symbol?"symbol":typeof t)||"function"==typeof t)?t:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this)).container.table;return o.cue.aimMode(),o.cue.showHelper(!0),o.cueball=s.container.rules.cueball,o.cue.moveTo(o.cueball.pos),s.container.view.camera.suggestMode(s.container.view.camera.aimView),o.cue.aimInputs.showOverlap(),s}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&l(e,t)}(n,e),t=[{key:"handleInput",value:function(e){switch(e.key){case"Space":this.container.table.cue.adjustPower(e.t*this.scale*.7);break;case"SpaceUp":return this.playShot();default:if(!this.commonKeyHandler(e))return this}return this.container.sendEvent(this.container.table.cue.aim),this}},{key:"handleBreak",value:function(e){return new o.e(this.container,e.init,e.shots,e.retry)}},{key:"playShot",value:function(){var e=new r.Qe(this.container.table.serialise());return this.container.sendEvent(e),this.container.recorder.record(e),new s.H(this.container)}}],function(e,t){for(var n=0;n{n.d(t,{Qe:()=>r.Q,pd:()=>i.p,xI:()=>s}),n("./src/events/beginevent.ts"),n("./src/events/aimevent.ts");var r=n("./src/events/hitevent.ts"),i=n("./src/events/input.ts");n("./src/events/abortevent.ts"),n("./src/events/stationaryevent.ts");var s=/*#__PURE__*/function(){var e;function t(e){var n,r;!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),r=void 0,(n="container")in this?Object.defineProperty(this,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):this[n]=r,this.container=e}return e=[{key:"handleInput",value:function(e){return this}},{key:"handleBegin",value:function(e){return this}},{key:"handleBreak",value:function(e){return this}},{key:"handleStartAim",value:function(e){return this}},{key:"handleAim",value:function(e){return this}},{key:"handleHit",value:function(e){return this}},{key:"handleAbort",value:function(e){return this}},{key:"handleWatch",value:function(e){return this}},{key:"handlePlaceBall",value:function(e){return this}},{key:"handleStationary",value:function(e){return this}},{key:"handleChat",value:function(e){return this}},{key:"handleRejoin",value:function(e){return this}},{key:"onFirst",value:function(){}}],function(e,t){for(var n=0;n{n.d(t,{y:()=>f});var r=n("./src/controller/controller.ts"),i=n("./src/controller/end.ts"),s=n("./src/utils/gltf.ts"),o=n("./src/model/outcome.ts"),a=n("./node_modules/three/build/three.module.js");function l(e){return(l=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function u(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function h(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(h=function(){return!!e})()}var f=/*#__PURE__*/function(e){var t;function n(){var e,t,r,i,s;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,n),t=n,r=arguments,t=l(t),(i="scale")in(e=(s=h()?Reflect.construct(t,r||[],l(this).constructor):t.apply(this,r))&&("object"===u(s)||"function"==typeof s)?s:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this))?Object.defineProperty(e,i,{value:.001,enumerable:!0,configurable:!0,writable:!0}):e[i]=.001,e}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c(e,t)}(n,e),t=[{key:"handleAbort",value:function(e){return new i.o(this.container)}},{key:"handleChat",value:function(e){var t=e.sender?"".concat(e.sender,":"):"",n="".concat(t," ").concat(e.message);return this.container.chat.showMessage(n),this}},{key:"hit",value:function(){this.container.table.outcome=[o.P.hit(this.container.table.cueball,this.container.table.cue.aim.power)],this.container.table.hit(),this.container.view.camera.suggestMode(this.container.view.camera.aimView),this.container.table.cue.showHelper(!1)}},{key:"commonKeyHandler",value:function(e){var t=this.container.table.cue,n=e.t*this.scale;switch(e.key){case"ArrowLeft":return t.rotateAim(-n,this.container.table),!0;case"ArrowRight":return t.rotateAim(n,this.container.table),!0;case"ArrowDown":return t.adjustSpin(new a.Pq0(0,-n),this.container.table),!0;case"ArrowUp":return t.adjustSpin(new a.Pq0(0,n),this.container.table),!0;case"ShiftArrowLeft":return t.adjustSpin(new a.Pq0(n,0),this.container.table),!0;case"ShiftArrowRight":return t.adjustSpin(new a.Pq0(-n,0),this.container.table),!0;case"KeyPUp":return(0,s.KP)(this.container.view.scene),!0;case"KeyHUp":return t.toggleHelper(),!0;case"movementXUp":return t.rotateAim(2*n,this.container.table),!0;case"movementYUp":case"NumpadSubtract":return this.container.view.camera.adjustHeight(8*n),!0;case"NumpadAdd":return this.container.view.camera.adjustHeight(-(8*n)),!0;case"KeyOUp":return this.container.view.camera.toggleMode(),!0;case"KeyDUp":return this.togglePanel(),!0;case"KeyFUp":return this.toggleFullscreen(),!0;default:return!1}}},{key:"togglePanel",value:function(){this.container.sliders.toggleVisibility(),this.container.table.showSpin(!0),this.container.table.showTraces(!0),("undefined"==typeof process?"undefined":u(process))!=="object"&&console.log(this.container.table.serialise())}},{key:"toggleFullscreen",value:function(){document.fullscreenElement?document.exitFullscreen&&document.exitFullscreen():document.documentElement.requestFullscreen()}}],function(e,t){for(var n=0;n{function r(e){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function i(e,t){return(i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function s(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(s=function(){return!!e})()}n.d(t,{o:()=>o});var o=/*#__PURE__*/function(e){var t;function n(){var e,t,i;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,n),e=n,t=arguments,e=r(e),(i=s()?Reflect.construct(e,t||[],r(this).constructor):e.apply(this,t))&&("object"==(i&&"undefined"!=typeof Symbol&&i.constructor===Symbol?"symbol":typeof i)||"function"==typeof i)?i:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this)}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&i(e,t)}(n,e),t=[{key:"handleChat",value:function(e){var t=e.sender?"".concat(e.sender,":"):"",n="".concat(t," ").concat(e.message);return this.container.chat.showMessage(n),this}}],function(e,t){for(var n=0;n{n.d(t,{x:()=>p});var r=n("./src/controller/controllerbase.ts"),i=n("./src/controller/controller.ts"),s=n("./src/controller/aim.ts"),o=n("./src/events/breakevent.ts"),a=n("./src/model/physics/constants.ts"),l=n("./node_modules/three/build/three.module.js"),c=n("./src/view/cuemesh.ts");function u(e){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function h(e,t){return(h=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function f(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(f=function(){return!!e})()}var p=/*#__PURE__*/function(e){var t;function n(e){var t,r,i,s,o,l,c;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,n),r=n,i=[e],r=u(r),s=t=(c=f()?Reflect.construct(r,i||[],u(this).constructor):r.apply(this,i))&&("object"==(c&&"undefined"!=typeof Symbol&&c.constructor===Symbol?"symbol":typeof c)||"function"==typeof c)?c:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this),o="placescale",l=.02*a.R,o in s?Object.defineProperty(s,o,{value:l,enumerable:!0,configurable:!0,writable:!0}):s[o]=l,t.container.table.cue.moveTo(t.container.table.cueball.pos),t.container.table.cue.aim.power=0,t.container.view.camera.forceMode(t.container.view.camera.aimView),t}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&h(e,t)}(n,e),t=[{key:"onFirst",value:function(){var e=this.container.table.cueball;this.container.rules.allowsPlaceBall()&&e.pos.copy(this.container.rules.placeBall()),e.setStationary(),e.updateMesh(0),this.container.table.cue.placeBallMode(),this.container.table.cue.showHelper(!1),this.container.table.cue.moveTo(this.container.table.cueball.pos),this.container.table.cue.aimInputs.setButtonText("Place\nBall"),this.container.rules.allowsPlaceBall()||this.container.inputQueue.push(new i.pd(1,"SpaceUp"))}},{key:"handleInput",value:function(e){var t=this.container.table.cueball.pos;switch(e.key){case"ArrowLeft":case"KeyI":this.moveTo(0,e.t*this.placescale);break;case"ArrowRight":case"KeyK":this.moveTo(0,-e.t*this.placescale);break;case"movementXUp":this.moveTo(0,-e.t*this.placescale*2);break;case"movementYUp":this.moveTo(-e.t*this.placescale*2,0);break;case"KeyJ":this.moveTo(-e.t*this.placescale,0);break;case"KeyL":this.moveTo(e.t*this.placescale,0);break;case"SpaceUp":return this.placed();default:this.commonKeyHandler(e)}return this.container.table.cue.moveTo(t),this.container.view.camera.forceMove(this.container.table.cue.aim),this.container.sendEvent(this.container.table.cue.aim),this}},{key:"moveTo",value:function(e,t){var n=new l.Pq0(e,t),r=this.container.table.cueball.pos.add(n);r.copy(this.container.rules.placeBall(r)),c.l.indicateValid(!this.container.table.overlapsAny(r))}},{key:"placed",value:function(){return this.container.table.overlapsAny(this.container.table.cueball.pos)?this:(this.container.table.cue.aimInputs.setButtonText("Hit"),this.container.sound.playNotify(),this.container.sendEvent(new o.W(this.container.table.shortSerialise())),new s.m(this.container))}}],function(e,t){for(var n=0;n{function r(e){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function i(e,t){return(i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function s(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(s=function(){return!!e})()}n.d(t,{H:()=>o});var o=/*#__PURE__*/function(e){var t;function n(e){var t,i,o,a;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,n),i=n,o=[e],i=r(i),(t=(a=s()?Reflect.construct(i,o||[],r(this).constructor):i.apply(this,o))&&("object"==(a&&"undefined"!=typeof Symbol&&a.constructor===Symbol?"symbol":typeof a)||"function"==typeof a)?a:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this)).hit(),t}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&i(e,t)}(n,e),t=[{key:"handleStationary",value:function(e){var t=this.container.table,n=t.outcome,r=this.container.rules.update(n);return this.container.recorder.updateBreak(n),t.cue.aimAtNext(t.cueball,this.container.rules.nextCandidateBall()),r}},{key:"handleInput",value:function(e){return this.commonKeyHandler(e),this}}],function(e,t){for(var n=0;n{n.d(t,{e:()=>m});var r=n("./src/events/hitevent.ts"),i=n("./src/controller/controllerbase.ts"),s=n("./src/events/aimevent.ts"),o=n("./src/events/breakevent.ts"),a=n("./src/controller/aim.ts"),l=n("./src/events/eventtype.ts"),c=n("./src/events/rerackevent.ts");function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n3&&void 0!==arguments[3]&&arguments[3],u=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1500;if(!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,n),s=n,a=[e],s=f(s),h(l=(i=v()?Reflect.construct(s,a||[],f(this).constructor):s.apply(this,a))&&("object"==(i&&"undefined"!=typeof Symbol&&i.constructor===Symbol?"symbol":typeof i)||"function"==typeof i)?i:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this),"delay",void 0),h(l,"shots",void 0),h(l,"firstShot",void 0),h(l,"timer",void 0),h(l,"init",void 0),l.init=t,l.shots=d(r),l.firstShot=l.shots[0],l.delay=u,l.container.table.showTraces(!0),l.container.table.updateFromShortSerialised(l.init),c){var p=new o.W(t,r);p.retry=!0,l.container.eventQueue.push(p)}else l.container.view.camera.forceMode(l.container.view.camera.topView),l.playNextShot(1.5*l.delay);return l}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&p(e,t)}(n,e),t=[{key:"playNextShot",value:function(e){var t=this,n=this.shots.shift();if((null==n?void 0:n.type)===l.B.RERACK){c.x.fromJson(n.ballinfo).applyToController(this),this.shots.length>0&&this.playNextShot(e);return}var i=s.w.fromJson(n);this.container.table.cueball=this.container.table.balls[i.i],console.log(this.container.table.cueball.pos.distanceTo(i.pos)),this.container.table.cueball.pos.copy(i.pos),this.container.table.cue.aim=i,this.container.table.cue.updateAimInput(),this.container.table.cue.t=1,clearTimeout(this.timer),this.timer=setTimeout(function(){t.container.eventQueue.push(new r.Q(t.container.table.cue.aim)),t.timer=void 0},e)}},{key:"handleHit",value:function(e){return this.hit(),this}},{key:"handleStationary",value:function(e){return this.shots.length>0&&void 0===this.timer&&this.playNextShot(this.delay),this}},{key:"handleInput",value:function(e){return this.commonKeyHandler(e),this}},{key:"handleBreak",value:function(e){return(this.container.table.updateFromShortSerialised(e.init),this.shots=d(e.shots),this.container.table.showSpin(!0),e.retry)?this.retry():(this.playNextShot(this.delay),this)}},{key:"retry",value:function(){clearTimeout(this.timer),this.timer=void 0,this.container.table.updateFromShortSerialised(this.init);var e=s.w.fromJson(this.firstShot);return this.container.table.cueball=this.container.table.balls[e.i],this.container.rules.cueball=this.container.table.cueball,this.container.table.cueball.pos.copy(e.pos),this.container.table.cue.aim=e,this.container.view.camera.forceMode(this.container.view.camera.aimView),new a.m(this.container)}}],function(e,t){for(var n=0;n{n.d(t,{V:()=>M});var r=n("./src/events/watchevent.ts"),i=n("./src/utils/rack.ts"),s=n("./node_modules/three/build/three.module.js"),o=n("./src/controller/aim.ts"),a=n("./src/controller/placeball.ts"),l=n("./src/controller/watchaim.ts"),c=n("./src/events/chatevent.ts"),u=n("./src/events/placeballevent.ts"),h=n("./src/model/outcome.ts"),f=n("./src/model/table.ts"),p=n("./src/utils/utils.ts"),d=n("./src/controller/end.ts"),v=n("./src/model/physics/constants.ts"),m=n("./src/utils/respot.ts"),y=n("./src/view/tablegeometry.ts"),b=n("./src/events/startaimevent.ts");function g(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var w=/*#__PURE__*/function(){var e;function t(e){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),g(this,"container",void 0),g(this,"cueball",void 0),g(this,"currentBreak",0),g(this,"previousBreak",0),g(this,"score",0),g(this,"rulename","nineball"),this.container=e}return e=[{key:"startTurn",value:function(){this.previousBreak=this.currentBreak,this.currentBreak=0}},{key:"nextCandidateBall",value:function(){return m.k.closest(this.container.table.cueball,this.container.table.balls)}},{key:"placeBall",value:function(e){if(e){var t=new s.Pq0(-y.P.X/2,y.P.tableY),n=new s.Pq0(-y.P.tableX,-y.P.tableY);return e.clamp(n,t)}return new s.Pq0(-(11*v.R)/.5,0,0)}},{key:"asset",value:function(){return"models/p8.min.gltf"}},{key:"tableGeometry",value:function(){y.P.hasPockets=!0}},{key:"table",value:function(){var e=new f.X(this.rack());return this.cueball=e.cueball,e}},{key:"rack",value:function(){return i.m.diamond()}},{key:"update",value:function(e){var t=this.container.table;if(h.P.isCueBallPotted(t.cueball,e))return(this.startTurn(),this.container.isSinglePlayer)?new a.x(this.container):(this.container.sendEvent(new u.z(p.v_,!0)),new l.r(this.container));if(h.P.isBallPottedNoFoul(t.cueball,e)){var n=h.P.potCount(e);return(this.currentBreak+=n,this.score+=n,this.container.sound.playSuccess(t.inPockets()),this.isEndOfGame(e))?(this.container.eventQueue.push(new c.b(null,"game over")),this.container.recorder.wholeGameLink(),new d.o(this.container)):(this.container.sendEvent(new r.Q(t.serialise())),new o.m(this.container))}return(this.container.sendEvent(new b.M),this.container.isSinglePlayer)?(this.container.sendEvent(new r.Q(t.serialise())),this.startTurn(),new o.m(this.container)):new l.r(this.container)}},{key:"isPartOfBreak",value:function(e){return h.P.isBallPottedNoFoul(this.container.table.cueball,e)}},{key:"isEndOfGame",value:function(e){var t=this.container.table.balls.filter(function(e){return e.onTable()});return 1===t.length&&t[0]===this.cueball}},{key:"otherPlayersCueBall",value:function(){return this.cueball}},{key:"secondToPlay",value:function(){}},{key:"allowsPlaceBall",value:function(){return!0}}],function(e,t){for(var n=0;n{n.d(t,{c:()=>k});var r=n("./node_modules/three/build/three.module.js"),i=n("./src/events/watchevent.ts"),s=n("./src/model/outcome.ts"),o=n("./src/utils/rack.ts"),a=n("./src/utils/respot.ts"),l=n("./src/controller/aim.ts"),c=n("./src/controller/watchaim.ts"),u=n("./src/events/chatevent.ts"),h=n("./src/controller/end.ts"),f=n("./src/model/table.ts"),p=n("./src/view/tablegeometry.ts"),d=n("./src/controller/placeball.ts"),v=n("./src/events/placeballevent.ts"),m=n("./src/utils/utils.ts"),y=/*#__PURE__*/function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t)}return e=[{key:"shotInfo",value:function(e,n,r){var i=s.P.firstCollision(n);return{pots:s.P.potCount(n),firstCollision:i,legalFirstCollision:t.isLegalFirstCollision(e,r,i),whitePotted:s.P.isCueBallPotted(e.cueball,n)}}},{key:"isLegalFirstCollision",value:function(e,n,r){if(!r)return!1;var i=r.ballB.id;return n?i>=7:!(t.coloursOnTable(e).filter(function(e){return e.id0)}},{key:"respotAllPottedColours",value:function(e,t){return s.P.pots(t).filter(function(e){return e.id<7}).filter(function(e){return 0!==e.id}).map(function(t){return a.k.respot(t,e)})}},{key:"redsOnTable",value:function(e){return e.balls.slice(7).filter(function(e){return e.onTable()})}},{key:"coloursOnTable",value:function(e){return e.balls.slice(1,7).filter(function(e){return e.onTable()})}}],function(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,r=Array(t);n0,this.switchPlayer()}return this.targetIsRed?this.targetRedRule(e,t):this.targetColourRule(e,t)}},{key:"targetRedRule",value:function(e,t){return(console.log("applying target red rule"),t.legalFirstCollision&&s.P.onlyRedsPotted(e))?(this.currentBreak+=t.pots,this.targetIsRed=!1,this.previousPotRed=!0,this.container.hud.updateBreak(this.currentBreak),this.continueBreak()):(this.foulPoints=this.foulCalculation(e,t),this.respot(e),t.whitePotted)?this.whiteInHand():this.switchPlayer()}},{key:"targetColourRule",value:function(e,t){if(console.log("applying target colour rule"),t.whitePotted)return this.respot(e),this.whiteInHand();if(t.pots>1)return this.foulPoints=this.foulCalculation(e,t),this.respot(e),this.switchPlayer();if(s.P.pots(e)[0].id>6)return this.foulPoints=this.foulCalculation(e,t),this.switchPlayer();this.targetIsRed=y.redsOnTable(this.container.table).length>0;var n=s.P.pots(e)[0].id;return n!==t.firstCollision.ballB.id?this.foul(e,t):this.previousPotRed?(this.respot(e),this.currentBreak+=n+1,this.previousPotRed=!1,this.continueBreak()):y.coloursOnTable(this.container.table).filter(function(e){return e.id0?this.foul(e,t):(this.currentBreak+=n+1,this.previousPotRed=!1,this.continueBreak())}},{key:"foul",value:function(e,t){return this.foulPoints=this.foulCalculation(e,t),this.respot(e),this.switchPlayer()}},{key:"foulCalculation",value:function(e,t){var n,r,i,o,a=s.P.pots(e).map(function(e){return e.id}).filter(function(e){return e<7}),l=null!==(o=null===(i=t.firstCollision)||void 0===i?void 0:null===(r=i.ballB)||void 0===r?void 0:r.id)&&void 0!==o?o:0;return l>6&&(l=0),(n=Math).max.apply(n,[3,l].concat(function(e){if(Array.isArray(e))return g(e)}(a)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(a)||function(e,t){if(e){if("string"==typeof e)return g(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return g(e,void 0)}}(a)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()))+1}},{key:"tableGeometry",value:function(){p.P.hasPockets=!0}},{key:"table",value:function(){var e=new f.X(this.rack());return this.cueball=e.cueball,e}},{key:"otherPlayersCueBall",value:function(){return this.cueball}},{key:"secondToPlay",value:function(){}},{key:"isPartOfBreak",value:function(e){return this.currentBreak>0}},{key:"isEndOfGame",value:function(e){return s.P.isClearTable(this.container.table)&&this.currentBreak>0}},{key:"allowsPlaceBall",value:function(){return!0}},{key:"asset",value:function(){return t.tablemodel}},{key:"startTurn",value:function(){this.previousPotRed=!1,this.targetIsRed=y.redsOnTable(this.container.table).length>0,this.previousBreak=this.currentBreak,this.score+=this.currentBreak,this.currentBreak=0,this.container.hud.updateBreak(this.currentBreak)}},{key:"rack",value:function(){return o.m.snooker()}},{key:"nextCandidateBall",value:function(){var e=this.container.table,t=y.redsOnTable(e),n=y.coloursOnTable(e);return this.previousPotRed?a.k.closest(e.cueball,n):t.length>0?a.k.closest(e.cueball,t):n.length>0?n[0]:void 0}},{key:"placeBall",value:function(e){if(e){var t=new r.Pq0(o.m.baulk,0,0),n=o.m.sixth,i=e.distanceTo(t);if(e.x>=o.m.baulk&&(e.x=o.m.baulk),!(i>n))return e;var s=e.clone().sub(t).normalize();return t.add(s.multiplyScalar(n))}return new r.Pq0(o.m.baulk,-o.m.sixth/2.6,0)}},{key:"switchPlayer",value:function(){this.foulPoints>0&&console.log("foul, ".concat(this.foulPoints," to opponent")),console.log("end of break, switch player");var e=this.container.table;return(console.log(e.cue.aim),this.container.sendEvent(new b.M(this.foulPoints)),this.container.isSinglePlayer)?(this.container.sendEvent(new i.Q(e.serialise())),this.startTurn(),new l.m(this.container)):new c.r(this.container)}},{key:"continueBreak",value:function(){this.container.hud.updateBreak(this.currentBreak);var e=this.container.table;return(this.container.sound.playSuccess(e.inPockets()),s.P.isClearTable(e))?(this.container.eventQueue.push(new u.b(null,"game over")),this.container.recorder.wholeGameLink(),new h.o(this.container)):(this.container.sendEvent(new i.Q(e.serialise())),new l.m(this.container))}},{key:"whiteInHand",value:function(){return(this.foulPoints>0&&console.log("foul, ".concat(this.foulPoints," to opponent")),this.startTurn(),this.container.isSinglePlayer)?new d.x(this.container):(this.container.sendEvent(new v.z(m.v_,!0)),new c.r(this.container))}},{key:"update",value:function(e){return this.snookerrule(e)}},{key:"respot",value:function(e){var t=y.respotAllPottedColours(this.container.table,e);if(t.length>0){var n={balls:t.map(function(e){return e.serialise()}),rerack:!0},r=new i.Q(n);this.container.sendEvent(r),this.container.recorder.record(r)}}}],function(e,t){for(var n=0;n{n.d(t,{r:()=>a});var r=n("./src/controller/watchshot.ts");function i(e){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function o(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(o=function(){return!!e})()}var a=/*#__PURE__*/function(e){var t;function n(e){var t,r,s,a;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,n),r=n,s=[e],r=i(r),(t=(a=o()?Reflect.construct(r,s||[],i(this).constructor):r.apply(this,s))&&("object"==(a&&"undefined"!=typeof Symbol&&a.constructor===Symbol?"symbol":typeof a)||"function"==typeof a)?a:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this)).container.table.cueball=t.container.rules.otherPlayersCueBall(),t.container.table.cue.moveTo(t.container.table.cueball.pos),t.container.view.camera.suggestMode(t.container.view.camera.topView),t}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}(n,e),t=[{key:"handleAim",value:function(e){return this.container.table.cue.aim=e,this.container.table.cueball.pos.copy(e.pos),this}},{key:"handleHit",value:function(e){return this.container.table.updateFromSerialised(e.tablejson),new r.O(this.container)}}],function(e,t){for(var n=0;n{n.d(t,{O:()=>u});var r=n("./src/controller/aim.ts"),i=n("./src/controller/watchaim.ts"),s=n("./src/controller/controllerbase.ts"),o=n("./src/controller/placeball.ts");function a(e){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function l(e,t){return(l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(c=function(){return!!e})()}var u=/*#__PURE__*/function(e){var t;function n(e){var t,r,i,s;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,n),r=n,i=[e],r=a(r),(t=(s=c()?Reflect.construct(r,i||[],a(this).constructor):r.apply(this,i))&&("object"==(s&&"undefined"!=typeof Symbol&&s.constructor===Symbol?"symbol":typeof s)||"function"==typeof s)?s:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this)).container.table.outcome=[],t.container.table.hit(),t}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&l(e,t)}(n,e),t=[{key:"handleStartAim",value:function(e){return new r.m(this.container)}},{key:"handlePlaceBall",value:function(e){return new o.x(this.container)}},{key:"handleWatch",value:function(e){return"rerack"in e.json?(console.log("Respot"),this.container.table.updateFromSerialised(e.json),this):new i.r(this.container)}}],function(e,t){for(var n=0;n{var r,i,s,o,a,l,c,u,h,f=n("./src/model/physics/physics.ts"),p=n("./node_modules/three/build/three.module.js");function d(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var v=/*#__PURE__*/function(){var e;function t(e,n){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),d(this,"canvas",void 0),d(this,"context",void 0),d(this,"endx",100),d(this,"endy",100),d(this,"scale",2e3),d(this,"r",20),e.firstElementChild.innerHTML=n,this.canvas=e.lastElementChild,this.context=this.canvas.getContext("2d")}return e=[{key:"drawBall",value:function(){this.context.beginPath(),this.context.strokeStyle="lightgray",this.context.fillStyle="beige",this.context.arc(this.endx,this.endy,this.r,0,2*Math.PI,!1),this.context.fill(),this.context.stroke()}},{key:"drawCushion",value:function(){var e=this.context.createLinearGradient(10,90,200,90);e.addColorStop(0,"lightgray"),e.addColorStop(.75,"white"),this.context.fillStyle=e,this.context.fillRect(this.endx+this.r,10,200,250)}},{key:"plot",value:function(e,t,n,r,i){this.context.clearRect(0,0,this.canvas.width,this.canvas.height),this.drawCushion(),this.drawBall();for(var s=e;s<=t;s+=n){var o=r(s),a=i(s),l=(0,f.yO)(o,a)?[]:[2,2];this.context.setLineDash(l);var c=(s+360)*101%360;this.context.strokeStyle="hsl(".concat(c,",50%,50%)"),this.drawArrow(this.endx-o.x*this.scale,this.endy-o.y*this.scale,this.endx,this.endy);var u=(0,f.QK)(0,o,a,f.QV);o.add(u.v),this.drawArrow(this.endx,this.endy,this.endx+o.x*this.scale,this.endy+o.y*this.scale)}}},{key:"drawArrow",value:function(e,t,n,r){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:.9,s={dx:n-e,dy:r-t},o={x:s.dx*i+e,y:s.dy*i+t},a={dx:n-o.x,dy:r-o.y};this.context.beginPath(),this.context.moveTo(e,t),this.context.lineTo(o.x,o.y),this.context.moveTo(o.x+.5*a.dy,o.y-.5*a.dx),this.context.lineTo(o.x-.5*a.dy,o.y+.5*a.dx),this.context.lineTo(n,r),this.context.closePath(),this.context.stroke()}}],function(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,r=Array(t);n{n.d(t,{h:()=>l});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function a(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(a=function(){return!!e})()}var l=/*#__PURE__*/function(e){var t;function n(){var e,t,r,o;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,n),t=s(t=n),(e=(o=a()?Reflect.construct(t,[],s(this).constructor):t.apply(this,r))&&("object"==(o&&"undefined"!=typeof Symbol&&o.constructor===Symbol?"symbol":typeof o)||"function"==typeof o)?o:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this)).type=i.B.ABORT,e}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&o(e,t)}(n,e),t=[{key:"applyToController",value:function(e){return e.handleAbort(this)}}],function(e,t){for(var n=0;n{n.d(t,{w:()=>f});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts"),s=n("./src/utils/utils.ts"),o=n("./node_modules/three/build/three.module.js");function a(e,t){for(var n=0;n{n.d(t,{u:()=>l});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function a(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(a=function(){return!!e})()}var l=/*#__PURE__*/function(e){var t;function n(){var e,t,r,o;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,n),t=s(t=n),(e=(o=a()?Reflect.construct(t,[],s(this).constructor):t.apply(this,r))&&("object"==(o&&"undefined"!=typeof Symbol&&o.constructor===Symbol?"symbol":typeof o)||"function"==typeof o)?o:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this)).type=i.B.BEGIN,e}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&o(e,t)}(n,e),t=[{key:"applyToController",value:function(e){return e.handleBegin(this)}}],function(e,t){for(var n=0;n{n.d(t,{W:()=>u});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function s(e,t){for(var n=0;n{n.d(t,{b:()=>u});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function s(e,t){for(var n=0;n{n.d(t,{B:()=>r});var r=/*#__PURE__*/function(e){return e.BEGIN="BEGIN",e.BREAK="BREAK",e.WATCHAIM="WATCHAIM",e.AIM="AIM",e.HIT="HIT",e.STATIONARY="STATIONARY",e.CHAT="CHAT",e.ABORT="ABORT",e.PLACEBALL="PLACEBALL",e.REJOIN="REJOIN",e.RERACK="RERACK",e.STARTAIM="STARTAIM",e}({})},"./src/events/gameevent.ts":(e,t,n)=>{function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}n.d(t,{F:()=>i});var i=function e(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,e),r(this,"type",void 0),r(this,"sequence",void 0)}},"./src/events/hitevent.ts":(e,t,n)=>{n.d(t,{Q:()=>c});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function s(e,t){for(var n=0;n{function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}n.d(t,{p:()=>i});var i=function e(t,n){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,e),r(this,"t",void 0),r(this,"key",void 0),this.t=t,this.key=n}},"./src/events/keyboard.ts":(e,t,n)=>{n.d(t,{s:()=>a});var r=n("./src/events/input.ts"),i=n("./node_modules/interactjs/dist/interact.min.js"),s=/*#__PURE__*/n.n(i);function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var a=/*#__PURE__*/function(){var e;function t(e){var n=this;!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),o(this,"pressed",{}),o(this,"released",{}),o(this,"keydown",function(e){null==n.pressed[e.code]&&(n.pressed[e.code]=performance.now()),e.stopImmediatePropagation(),"F12"!==e.key&&e.preventDefault()}),o(this,"keyup",function(e){n.released[e.code]=performance.now()-n.pressed[e.code],delete n.pressed[e.code],e.stopImmediatePropagation(),"F12"!==e.key&&e.preventDefault()}),o(this,"mousetouch",function(e){var t,r,i=n.released,s=e.client.yMath.abs(i.movementY)&&(i.movementY=0)}),this.addHandlers(e),/Android|iPhone/i.test(navigator.userAgent)||(e.contentEditable="true")}return e=[{key:"getEvents",value:function(){var e=this,t=Object.keys(this.pressed).filter(function(e){return!/Shift/.test(e)}).filter(function(e){return!/Control/.test(e)}),n=Object.keys(this.pressed).some(function(e){return/Shift/.test(e)}),i=Object.keys(this.pressed).some(function(e){return/Control/.test(e)}),s=[];return t.forEach(function(t){var o=performance.now()-e.pressed[t];s.push(new r.p(i?o/3:o,n?"Shift"+t:t)),"Space"!=t&&(e.pressed[t]=performance.now())}),Object.keys(this.released).forEach(function(t){return s.push(new r.p(e.released[t],t+"Up"))}),this.released={},s}},{key:"addHandlers",value:function(e){var t=this;e.addEventListener("keydown",this.keydown),e.addEventListener("keyup",this.keyup),e.focus(),s()(e).draggable({listeners:{move:function(e){t.mousetouch(e)}}}),s()(e).gesturable({onmove:function(e){e.dx/=3,t.mousetouch(e)}})}}],function(e,t){for(var n=0;n{n.d(t,{z:()=>h});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts"),s=n("./src/utils/utils.ts");function o(e,t){for(var n=0;n{n.d(t,{x:()=>c});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function s(e,t){for(var n=0;n{n.d(t,{M:()=>c});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function s(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:0;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,r),t=o(t=r),(s="foul")in(a=(e=l()?Reflect.construct(t,[],o(this).constructor):t.apply(this,n))&&("object"==(e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e)||"function"==typeof e)?e:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this))?Object.defineProperty(a,s,{value:0,enumerable:!0,configurable:!0,writable:!0}):a[s]=0,a.type=i.B.STARTAIM,a.foul=c,a}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&a(e,t)}(r,e),t=[{key:"applyToController",value:function(e){return e.handleStartAim(this)}}],n=[{key:"fromJson",value:function(e){return new r(e.foul)}}],t&&s(r.prototype,t),n&&s(r,n),r}(r.F)},"./src/events/stationaryevent.ts":(e,t,n)=>{n.d(t,{T:()=>l});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function a(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(a=function(){return!!e})()}var l=/*#__PURE__*/function(e){var t;function n(){var e,t,r,o;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,n),t=s(t=n),(e=(o=a()?Reflect.construct(t,[],s(this).constructor):t.apply(this,r))&&("object"==(o&&"undefined"!=typeof Symbol&&o.constructor===Symbol?"symbol":typeof o)||"function"==typeof o)?o:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this)).type=i.B.STATIONARY,e}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&o(e,t)}(n,e),t=[{key:"applyToController",value:function(e){return e.handleStationary(this)}}],function(e,t){for(var n=0;n{n.d(t,{Q:()=>c});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function s(e,t){for(var n=0;n{n.d(t,{c:()=>d,U:()=>p});var r=n("./src/utils/utils.ts"),i=n("./src/model/physics/physics.ts"),s=n("./node_modules/three/build/three.module.js"),o=n("./src/model/physics/constants.ts");function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var l=/*#__PURE__*/function(){var e;function t(e,n){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),a(this,"line",void 0),a(this,"geometry",void 0),a(this,"positions",void 0),a(this,"lastPos",new s.Pq0),a(this,"lastVel",new s.Pq0),this.geometry=new s.LoY,this.positions=new Float32Array(3*e),this.geometry.setAttribute("position",new s.THS(this.positions,3)),this.reset();var r=new s.mrM({color:n,opacity:.25,linewidth:3,transparent:!0});this.line=new s.N1A(this.geometry,r),this.line.visible=!1}return e=[{key:"reset",value:function(){this.geometry.setDrawRange(0,0),this.lastVel.setZ(1)}},{key:"forceTrace",value:function(e){this.lastVel.z=1,this.addTraceGiven(e,this.lastVel,1,.1,1)}},{key:"addTrace",value:function(e,t){if(0!==t.length()){var n=this.lastVel.angleTo(t),r=n>Math.PI/32?.01*o.R:o.R,i=this.lastPos.distanceTo(e);this.addTraceGiven(e,t,i,r,n)}}},{key:"addTraceGiven",value:function(e,t,n,r,i){var s=this.geometry.drawRange.count;0!==s&&n1&&i<1e-4&&s--,this.lastPos.copy(e),this.lastVel.copy(t),this.addPoint(e,s))}},{key:"addPoint",value:function(e,t){var n=3*t;n>this.positions.length||(this.positions[n++]=e.x,this.positions[n++]=e.y,this.positions[n]=e.z,this.geometry.setDrawRange(0,t+1),this.line.geometry.attributes.position.needsUpdate=!0)}}],function(e,t){for(var n=0;nMath.abs(this.rvel.z))&&(this.setStationary(),!0)}},{key:"setStationary",value:function(){this.vel.copy(r.v_),this.rvel.copy(r.v_),this.state="Stationary"}},{key:"isRolling",value:function(){return 0!==this.vel.lengthSq()&&0!==this.rvel.lengthSq()&&(0,i.Mq)(this.vel,this.rvel).length(){function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}n.d(t,{P:()=>i});var i=/*#__PURE__*/function(){var e;function t(e,n,i,s){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),r(this,"type",void 0),r(this,"timestamp",void 0),r(this,"ballA",null),r(this,"ballB",null),r(this,"incidentSpeed",void 0),this.type=e,this.ballA=n,this.ballB=i,this.incidentSpeed=s,this.timestamp=Date.now()}return e=[{key:"pot",value:function(e,n){return new t("Pot",e,e,n)}},{key:"cushion",value:function(e,n){return new t("Cushion",e,e,n)}},{key:"collision",value:function(e,n,r){return new t("Collision",e,n,r)}},{key:"hit",value:function(e,n){return new t("Hit",e,e,n)}},{key:"isCueBallPotted",value:function(e,t){return t.some(function(t){return"Pot"==t.type&&t.ballA===e})}},{key:"isBallPottedNoFoul",value:function(e,n){return n.some(function(e){return"Pot"==e.type&&null!==e.ballA})&&!t.isCueBallPotted(e,n)}},{key:"pots",value:function(e){return e.filter(function(e){return"Pot"==e.type}).map(function(e){return e.ballA})}},{key:"potCount",value:function(e){return this.pots(e).length}},{key:"onlyRedsPotted",value:function(e){return this.pots(e).every(function(e){return e.id>6})}},{key:"firstCollision",value:function(e){var t=e.filter(function(e){return"Collision"===e.type});return t.length>0?t[0]:void 0}},{key:"isClearTable",value:function(e){var t=e.balls.filter(function(e){return e.onTable()});return 1===t.length&&t[0]===e.cueball}},{key:"isThreeCushionPoint",value:function(e,n){n=t.cueBallFirst(e,n).filter(function(t){return t.ballA===e});var r=new Set,i=0,s=!0,o=!1,a=void 0;try{for(var l,c=n[Symbol.iterator]();!(s=(l=c.next()).done);s=!0){var u=l.value;if("Cushion"===u.type&&i++,"Collision"===u.type&&(r.add(u.ballB),2===r.size))return i>=3}}catch(e){o=!0,a=e}finally{try{s||null==c.return||c.return()}finally{if(o)throw a}}return!1}},{key:"cueBallFirst",value:function(e,t){return t.forEach(function(t){"Collision"===t.type&&t.ballB===e&&(t.ballB=t.ballA,t.ballA=e)}),t}}],function(e,t){for(var n=0;n{n.d(t,{M:()=>r,R:()=>i,_:()=>a,ee:()=>s,o:()=>o});var r=.1406,i=.02625,s=.98,o=.212,a=.14},"./src/model/physics/claude/qwen.ts":(e,t,n)=>{n.d(t,{z:()=>s});var r=n("./src/model/physics/constants.ts");function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var s=/*#__PURE__*/function(){var e;function t(e,n,r,s,o){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),i(this,"P",0),i(this,"WzI",0),i(this,"vx",void 0),i(this,"vy",void 0),i(this,"ωx",void 0),i(this,"ωy",void 0),i(this,"ωz",void 0),i(this,"s",void 0),i(this,"φ",void 0),i(this,"sʹ",void 0),i(this,"φʹ",void 0),i(this,"i",0),i(this,"N",100),i(this,"M",void 0),i(this,"R",void 0),i(this,"μs",void 0),i(this,"μw",void 0),i(this,"ee",void 0),this.M=e,this.R=n,this.ee=r,this.μs=s,this.μw=o}return e=[{key:"updateSlipSpeedsAndAngles",value:function(){var e=this.R,t=this.vx+this.ωy*e*r.Z3-this.ωz*e*r.o5,n=-this.vy*r.Z3+this.ωx*e,i=this.vx-this.ωy*e,s=this.vy+this.ωx*e;this.s=Math.sqrt(Math.pow(t,2)+Math.pow(n,2)),this.φ=Math.atan2(n,t),this.φ<0&&(this.φ+=2*Math.PI),this.sʹ=Math.sqrt(Math.pow(i,2)+Math.pow(s,2)),this.φʹ=Math.atan2(s,i),this.φʹ<0&&(this.φʹ+=2*Math.PI)}},{key:"compressionPhase",value:function(){for(var e=Math.max(this.M*this.vy/this.N,.001);this.vy>0;)this.updateSingleStep(e)}},{key:"restitutionPhase",value:function(e){var t=Math.max(e/this.N,.001);for(this.WzI=0;this.WzI10*this.N)throw"Solution not found"}},{key:"updateVelocity",value:function(e){var t=this.μs,n=this.μw,i=this.M;this.vx-=1/i*(n*Math.cos(this.φ)+t*Math.cos(this.φʹ)*(r.Z3+n*Math.sin(this.φ)*r.o5))*e,this.vy-=1/i*(r.o5-n*r.Z3*Math.sin(this.φ)+t*Math.sin(this.φʹ)*(r.Z3+n*Math.sin(this.φ)*r.o5))*e}},{key:"updateAngularVelocity",value:function(e){var t=this.μs,n=this.μw,i=this.M,s=this.R;this.ωx+=-(5/(2*i*s))*(n*Math.sin(this.φ)+t*Math.sin(this.φʹ)*(r.Z3+n*Math.sin(this.φ)*r.o5))*e,this.ωy+=-(5/(2*i*s))*(n*Math.cos(this.φ)*r.Z3-t*Math.cos(this.φʹ)*(r.Z3+n*Math.sin(this.φ)*r.o5))*e,this.ωz+=5/(2*i*s)*(n*Math.cos(this.φ)*r.o5)*e}},{key:"updateWorkDone",value:function(e){var t=e*Math.abs(this.vy);this.WzI+=t,this.P+=e}},{key:"solvePaper",value:function(e,t,n,r){this.solve(e*Math.cos(t),e*Math.sin(t),-r*Math.sin(t),r*Math.cos(t),n)}},{key:"solve",value:function(e,t,n,r,i){this.vx=e,this.vy=t,this.ωx=n,this.ωy=r,this.ωz=i,this.WzI=0,this.P=0,this.i=0,this.compressionPhase();var s=this.WzI-(1-this.ee*this.ee)*this.WzI;this.restitutionPhase(s)}}],function(e,t){for(var n=0;n{n.d(t,{I:()=>s,Mz:()=>r,Qg:()=>b,R:()=>f,Wv:()=>w,Ys:()=>k,Z3:()=>d,cM:()=>x,e:()=>p,g:()=>o,gT:()=>c,gf:()=>l,jG:()=>y,kL:()=>u,kM:()=>T,m:()=>h,mu:()=>a,o5:()=>v,x3:()=>i,xO:()=>g});var r,i,s,o=9.8,a=.00985,l=.16,c=.8,u=.034,h=.23,f=.03275,p=.86,d=.4,v=Math.sqrt(21)/5;function m(){r=a*h*o*2/3*u,i=7/(5*Math.sqrt(2))*f*a*h*o,s=.4*h*f*f}function y(e){f=e,m()}function b(e){h=e,m()}function g(e){a=e,m()}function w(e){u=e,m()}function k(e){l=e}function x(e){p=e}function T(e){c=e}m()},"./src/model/physics/knuckle.ts":(e,t,n)=>{n.d(t,{O:()=>a});var r=n("./src/model/physics/constants.ts"),i=n("./src/view/pocketgeometry.ts");function s(e,t){for(var n=0;n{n.d(t,{$8:()=>S,Gp:()=>k,JD:()=>f,Mq:()=>c,QK:()=>d,QV:()=>R,Qy:()=>M,Un:()=>w,c0:()=>g,lx:()=>p,p2:()=>h,s0:()=>b,t6:()=>_,yO:()=>x});var r=n("./node_modules/three/build/three.module.js"),i=n("./src/utils/utils.ts"),s=n("./src/model/physics/constants.ts"),o=n("./src/model/physics/claude/qwen.ts"),a=n("./src/model/physics/claude/constants.ts"),l=new r.Pq0;function c(e,t){return l.copy(e).addScaledVector((0,i.KM)(t),s.R)}var u={v:new r.Pq0,w:new r.Pq0};function h(e,t){var n=c(e,t).setZ(0);return u.v.copy((0,i.xb)(n).multiplyScalar(-s.gf*s.g)),u.w.copy((0,i.xb)((0,i.KM)(n)).multiplyScalar(2.5*s.gf*s.g/s.R)),u.w.setZ(-2.5*(s.Mz/(s.m*s.R*s.R))*Math.sign(t.z)),u}function f(e){var t=new r.Pq0(e.x,e.y,0).length(),n=5/7*s.x3/(s.m*s.R)/t,i=5/7*s.x3/(s.m*s.R*s.R)/t;return u.v.set(-n*e.y,n*e.x,0),u.w.set(-i*e.x,-i*e.y,-2.5*(s.Mz/(s.m*s.R*s.R))*Math.sign(e.z)),u}function p(e,t){var n=t.z;t.copy((0,i.KM)(e).multiplyScalar(1/s.R)),t.setZ(n)}function d(e,t,n,r){var s=r(t.clone().applyAxisAngle(i.up,e),n.clone().applyAxisAngle(i.up,e));return s.v.applyAxisAngle(i.up,-e),s.w.applyAxisAngle(i.up,-e),s}Object.freeze(u);var v=Math.asin(.1*s.R/s.R),m=Math.sin(v),y=Math.cos(v);function b(e,t){return new r.Pq0(e.x*m-e.z*y+s.R*t.y,-e.y-s.R*t.z*y+s.R*t.x*m)}function g(e){return e.x*y}function w(e){var t=3.5/s.m;return e.length()/t}function k(e){var t,n=1/s.m,i=.39+.257*(t=new r.Pq0(e/y,0,0)).x-.044*t.x*t.x;return s.gT*((1+i)*e)/n}function x(e,t){var n=k(g(e));return w(b(e,t))<=n}function T(e,t){return{c:g(e),s:b(e,t),A:3.5/s.m,B:1/s.m}}function A(e,t){var n=T(e,t),r=n.c,i=n.s,o=n.A,a=n.B,l=(1+s.e)*(r/a);return E(-i.x/o*m-l*y,i.y/o,i.x/o*y-l*m)}function P(e,t){var n=T(e,t),r=n.c,i=n.B,o=(1+s.e)*(r/i),a=.471-.241*Math.atan2(Math.abs(e.y),e.x),l=Math.atan2(e.y,e.x),c=Math.cos(l);return E(-a*o*c*y-o*y,a*o*Math.sin(l),a*o*c*y-o*m)}function R(e,t){return x(e,t)?A(e,t):P(e,t)}function S(e,t){var n=A(e,t),r=P(e,t),i=Math.sign(e.y)===Math.sign(t.z)?Math.cos(Math.atan2(e.y,e.x)):1;return{v:r.v.lerp(n.v,i),w:r.w.lerp(n.w,i)}}function E(e,t,n){return{v:new r.Pq0(e/s.m,t/s.m),w:new r.Pq0(-s.R/s.I*t*m,s.R/s.I*(e*m-n*y),s.R/s.I*t*y)}}function O(e,t){var n=new o.z(s.m,s.R,a.ee,a.o,a._+.1);n.solve(e.x,e.y,t.x,t.y,t.z);var i=new r.Pq0(n.vx,n.vy,0),l=new r.Pq0(n.ωx,n.ωy,n.ωz);return{v:i.sub(e),w:l.sub(t)}}function M(e,t){return d(Math.PI/2,e,t,O)}function _(e,t){var n=Math.atan2(-e.x,e.y),r=2.5*t.length()*(e.length()*s.R)/(s.R*s.R),o=t.clone().normalize();return(0,i.KM)(o).applyAxisAngle(o,n).multiplyScalar(r)}},"./src/model/physics/pocket.ts":(e,t,n)=>{n.d(t,{Z:()=>l});var r=n("./src/model/ball.ts"),i=n("./src/model/physics/constants.ts"),s=n("./src/utils/utils.ts");function o(e,t){for(var n=0;nthis.radius-i.R){var o=this.pos.clone().sub(e.pos).normalize().setZ(0);n>-i.R/2&&(e.vel.addScaledVector(o,7*i.R*t*i.g),e.rvel.addScaledVector((0,s.KM)(o),7*t*i.g)),0>e.vel.dot(o)&&(e.ballmesh.trace.forceTrace(e.pos),e.vel.x=o.x*e.vel.length()/2,e.vel.y=o.y*e.vel.length()/2)}var a=this.restingDepth(e);n{n.d(t,{X:()=>b});var r=n("./src/view/tablegeometry.ts"),i=n("./src/model/physics/physics.ts"),s=n("./src/view/pocketgeometry.ts"),o=/*#__PURE__*/function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t)}return e=[{key:"bounceAny",value:function(e,n){var s=!(arguments.length>2)||void 0===arguments[2]||arguments[2],o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:i.$8,a=e.futurePosition(n);if(t.willBounceLong(a,s)){var l=a.y>r.P.tableY?-Math.PI/2:Math.PI/2;return t.bounceIn(l,e,o)}if(t.willBounceShort(a,s)){var c=a.x>r.P.tableX?0:Math.PI;return t.bounceIn(c,e,o)}}},{key:"willBounceShort",value:function(e,n){return n?t.willBounceShortSegment(s.f.pockets.pocketNW.knuckleSW.pos.y,s.f.pockets.pocketSW.knuckleNW.pos.y,e):t.willBounceShortSegment(r.P.Y,-r.P.Y,e)}},{key:"willBounceLong",value:function(e,n){return n?t.willBounceLongSegment(s.f.pockets.pocketNW.knuckleNE.pos.x,s.f.pockets.pocketN.knuckleNW.pos.x,e)||t.willBounceLongSegment(s.f.pockets.pocketN.knuckleNE.pos.x,s.f.pockets.pocketNE.knuckleNW.pos.x,e):t.willBounceLongSegment(-r.P.X,r.P.X,e)}},{key:"willBounceLongSegment",value:function(e,t,n){return n.x>e&&n.xr.P.tableY}},{key:"willBounceShortSegment",value:function(e,t,n){return n.y>t&&n.yr.P.tableX}},{key:"bounceIn",value:function(e,t,n){t.ballmesh.trace.forceTrace(t.futurePos);var r=(0,i.QK)(e,t.vel,t.rvel,n);return t.vel.add(r.v),t.rvel.add(r.w),r.v.length()}}],function(e,t){for(var n=0;n100)throw Error("Depth exceeded resolving collisions");this.balls.forEach(function(t){t.update(e)})}},{key:"prepareAdvanceAll",value:function(e){var t=this;return this.pairs.every(function(n){return t.prepareAdvancePair(n.a,n.b,e)})&&this.balls.every(function(n){return t.prepareAdvanceToCushions(n,e)})}},{key:"prepareAdvancePair",value:function(e,t,n){if(u.willCollide(e,t,n)){var r=u.collide(e,t);return this.outcome.push(v.P.collision(e,t,r)),!1}return!0}},{key:"prepareAdvanceToCushions",value:function(e,t){if(!e.onTable())return!0;var n=e.futurePosition(t);if(Math.abs(n.y)1&&void 0!==arguments[1]?arguments[1]:this.cueball;return this.balls.filter(function(e){return e!==t}).some(function(t){return t.pos.distanceTo(e)<2*c.R})}}],t=[{key:"fromSerialised",value:function(e){var t=new n(e.balls.map(function(e){return l.c.fromSerialised(e)}));return t.updateFromSerialised(e),t}}],e&&m(n.prototype,e),t&&m(n,t),n}()},"./src/utils/gltf.ts":(e,t,n)=>{n.d(t,{KP:()=>eR,Ro:()=>eS});var r=n("./node_modules/three/build/three.module.js");let i={POSITION:["byte","byte normalized","unsigned byte","unsigned byte normalized","short","short normalized","unsigned short","unsigned short normalized"],NORMAL:["byte normalized","short normalized"],TANGENT:["byte normalized","short normalized"],TEXCOORD:["byte","byte normalized","unsigned byte","short","short normalized","unsigned short"]};class s{constructor(){this.textureUtils=null,this.pluginCallbacks=[],this.register(function(e){return new y(e)}),this.register(function(e){return new b(e)}),this.register(function(e){return new x(e)}),this.register(function(e){return new T(e)}),this.register(function(e){return new A(e)}),this.register(function(e){return new P(e)}),this.register(function(e){return new g(e)}),this.register(function(e){return new w(e)}),this.register(function(e){return new k(e)}),this.register(function(e){return new R(e)}),this.register(function(e){return new S(e)}),this.register(function(e){return new E(e)}),this.register(function(e){return new O(e)}),this.register(function(e){return new M(e)})}register(e){return -1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return -1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}setTextureUtils(e){return this.textureUtils=e,this}parse(e,t,n,r){let i=new m,s=[];for(let e=0,t=this.pluginCallbacks.length;ee.toBlob(n,t)):("image/jpeg"===t?n=.92:"image/webp"===t&&(n=.8),e.convertToBlob({type:t,quality:n}))}class m{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.extensionsRequired={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter r"+r.sPf}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map},this.textureUtils=null}setPlugins(e){this.plugins=e}setTextureUtils(e){this.textureUtils=e}async writeAsync(e,t,n={}){this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},n),this.options.animations.length>0&&(this.options.trs=!0),await this.processInputAsync(e),await Promise.all(this.pending);let r=this.buffers,i=this.json;n=this.options;let s=this.extensionsUsed,o=this.extensionsRequired,a=new Blob(r,{type:"application/octet-stream"}),l=Object.keys(s),c=Object.keys(o);if(l.length>0&&(i.extensionsUsed=l),c.length>0&&(i.extensionsRequired=c),i.buffers&&i.buffers.length>0&&(i.buffers[0].byteLength=a.size),!0===n.binary){let e=new FileReader;e.readAsArrayBuffer(a),e.onloadend=function(){var n;let r=p(e.result),s=new DataView(new ArrayBuffer(8));s.setUint32(0,r.byteLength,!0),s.setUint32(4,5130562,!0);let o=p((n=JSON.stringify(i),new TextEncoder().encode(n).buffer),32),a=new DataView(new ArrayBuffer(8));a.setUint32(0,o.byteLength,!0),a.setUint32(4,0x4e4f534a,!0);let l=new ArrayBuffer(12),c=new DataView(l);c.setUint32(0,0x46546c67,!0),c.setUint32(4,2,!0);let u=12+a.byteLength+o.byteLength+s.byteLength+r.byteLength;c.setUint32(8,u,!0);let h=new Blob([l,a,o,s,r],{type:"application/octet-stream"}),f=new FileReader;f.readAsArrayBuffer(h),f.onloadend=function(){t(f.result)}}}else if(i.buffers&&i.buffers.length>0){let e=new FileReader;e.readAsDataURL(a),e.onloadend=function(){let n=e.result;i.buffers[0].uri=n,t(i)}}else t(i)}serializeUserData(e,t){if(0===Object.keys(e.userData).length)return;let n=this.options,r=this.extensionsUsed;try{let i=JSON.parse(JSON.stringify(e.userData));if(n.includeCustomExtensions&&i.gltfExtensions){for(let e in void 0===t.extensions&&(t.extensions={}),i.gltfExtensions)t.extensions[e]=i.gltfExtensions[e],r[e]=!0;delete i.gltfExtensions}Object.keys(i).length>0&&(t.extras=i)}catch(t){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+t.message)}}getUID(e,t=!1){if(!1===this.uids.has(e)){let t=new Map;t.set(!0,this.uid++),t.set(!1,this.uid++),this.uids.set(e,t)}return this.uids.get(e).get(t)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;let t=new r.Pq0;for(let n=0,r=e.count;n5e-4)return!1;return!0}createNormalizedNormalAttribute(e){let t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);let n=e.clone(),i=new r.Pq0;for(let e=0,t=n.count;e4?i=e.array[s*e.itemSize+n]:(0===n?i=e.getX(s):1===n?i=e.getY(s):2===n?i=e.getZ(s):3===n&&(i=e.getW(s)),!0===e.normalized&&(i=r.cj9.normalize(i,e.array))),t===o.FLOAT?h.setFloat32(p,i,!0):t===o.INT?h.setInt32(p,i,!0):t===o.UNSIGNED_INT?h.setUint32(p,i,!0):t===o.SHORT?h.setInt16(p,i,!0):t===o.UNSIGNED_SHORT?h.setUint16(p,i,!0):t===o.BYTE?h.setInt8(p,i):t===o.UNSIGNED_BYTE&&h.setUint8(p,i),p+=a}p%c!=0&&(p+=c-p%c)}let d={buffer:this.processBuffer(h.buffer),byteOffset:this.byteOffset,byteLength:u};return void 0!==s&&(d.target=s),s===o.ARRAY_BUFFER&&(d.byteStride=c),this.byteOffset+=u,l.bufferViews.push(d),{id:l.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){let t=this,n=t.json;return n.bufferViews||(n.bufferViews=[]),new Promise(function(r){let i=new FileReader;i.readAsArrayBuffer(e),i.onloadend=function(){let e=p(i.result),s={buffer:t.processBuffer(e),byteOffset:t.byteOffset,byteLength:e.byteLength};t.byteOffset+=e.byteLength,r(n.bufferViews.push(s)-1)}})}processAccessor(e,t,n,i){let s,a;let l=this.json;if(e.array.constructor===Float32Array)s=o.FLOAT;else if(e.array.constructor===Int32Array)s=o.INT;else if(e.array.constructor===Uint32Array)s=o.UNSIGNED_INT;else if(e.array.constructor===Int16Array)s=o.SHORT;else if(e.array.constructor===Uint16Array)s=o.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)s=o.BYTE;else if(e.array.constructor===Uint8Array)s=o.UNSIGNED_BYTE;else throw Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+e.array.constructor.name);if(void 0===n&&(n=0),(void 0===i||i===1/0)&&(i=e.count),0===i)return null;let c=function(e,t,n){let i={min:Array(e.itemSize).fill(Number.POSITIVE_INFINITY),max:Array(e.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let s=t;s4?n=e.array[s*e.itemSize+t]:(0===t?n=e.getX(s):1===t?n=e.getY(s):2===t?n=e.getZ(s):3===t&&(n=e.getW(s)),!0===e.normalized&&(n=r.cj9.normalize(n,e.array))),i.min[t]=Math.min(i.min[t],n),i.max[t]=Math.max(i.max[t],n)}return i}(e,n,i);void 0!==t&&(a=e===t.index?o.ELEMENT_ARRAY_BUFFER:o.ARRAY_BUFFER);let u=this.processBufferView(e,s,n,i,a),h={bufferView:u.id,byteOffset:u.byteOffset,componentType:s,count:i,max:c.max,min:c.min,type:{1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"}[e.itemSize]};return!0===e.normalized&&(h.normalized=!0),l.accessors||(l.accessors=[]),l.accessors.push(h)-1}processImage(e,t,n,i="image/png"){if(null!==e){let s=this,o=s.cache,a=s.json,l=s.options,c=s.pending;o.images.has(e)||o.images.set(e,{});let u=o.images.get(e),h=i+":flipY/"+n.toString();if(void 0!==u[h])return u[h];a.images||(a.images=[]);let f={mimeType:i},p=d();p.width=Math.min(e.width,l.maxTextureSize),p.height=Math.min(e.height,l.maxTextureSize);let m=p.getContext("2d",{willReadFrequently:!0});if(!0===n&&(m.translate(0,p.height),m.scale(1,-1)),void 0!==e.data){t!==r.GWd&&console.error("GLTFExporter: Only RGBAFormat is supported.",t),(e.width>l.maxTextureSize||e.height>l.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);let n=new Uint8ClampedArray(e.height*e.width*4);for(let t=0;ts.processBufferViewImage(e)).then(e=>{f.bufferView=e})):void 0!==p.toDataURL?f.uri=p.toDataURL(i):c.push(v(p,i).then(e=>new FileReader().readAsDataURL(e)).then(e=>{f.uri=e}));let y=a.images.push(f)-1;return u[h]=y,y}throw Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(e){let t=this.json;t.samplers||(t.samplers=[]);let n={magFilter:l[e.magFilter],minFilter:l[e.minFilter],wrapS:l[e.wrapS],wrapT:l[e.wrapT]};return t.samplers.push(n)-1}async processTextureAsync(e){let t=this.options,n=this.cache,i=this.json;if(n.textures.has(e))return n.textures.get(e);i.textures||(i.textures=[]),e instanceof r.FvD&&(e=await this.decompressTextureAsync(e,t.maxTextureSize));let s=e.userData.mimeType;"image/webp"===s&&(s="image/png");let o={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,s)};e.name&&(o.name=e.name),await this._invokeAllAsync(async function(t){t.writeTexture&&await t.writeTexture(e,o)});let a=i.textures.push(o)-1;return n.textures.set(e,a),a}async processMaterialAsync(e){let t=this.cache,n=this.json;if(t.materials.has(e))return t.materials.get(e);if(e.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;n.materials||(n.materials=[]);let i={pbrMetallicRoughness:{}};!0!==e.isMeshStandardMaterial&&!0!==e.isMeshBasicMaterial&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");let s=e.color.toArray().concat([e.opacity]);if(h(s,[1,1,1,1])||(i.pbrMetallicRoughness.baseColorFactor=s),e.isMeshStandardMaterial?(i.pbrMetallicRoughness.metallicFactor=e.metalness,i.pbrMetallicRoughness.roughnessFactor=e.roughness):(i.pbrMetallicRoughness.metallicFactor=0,i.pbrMetallicRoughness.roughnessFactor=1),e.metalnessMap||e.roughnessMap){let t=await this.buildMetalRoughTextureAsync(e.metalnessMap,e.roughnessMap),n={index:await this.processTextureAsync(t),texCoord:t.channel};this.applyTextureTransform(n,t),i.pbrMetallicRoughness.metallicRoughnessTexture=n}if(e.map){let t={index:await this.processTextureAsync(e.map),texCoord:e.map.channel};this.applyTextureTransform(t,e.map),i.pbrMetallicRoughness.baseColorTexture=t}if(e.emissive){let t=e.emissive;if(Math.max(t.r,t.g,t.b)>0&&(i.emissiveFactor=e.emissive.toArray()),e.emissiveMap){let t={index:await this.processTextureAsync(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(t,e.emissiveMap),i.emissiveTexture=t}}if(e.normalMap){let t={index:await this.processTextureAsync(e.normalMap),texCoord:e.normalMap.channel};e.normalScale&&1!==e.normalScale.x&&(t.scale=e.normalScale.x),this.applyTextureTransform(t,e.normalMap),i.normalTexture=t}if(e.aoMap){let t={index:await this.processTextureAsync(e.aoMap),texCoord:e.aoMap.channel};1!==e.aoMapIntensity&&(t.strength=e.aoMapIntensity),this.applyTextureTransform(t,e.aoMap),i.occlusionTexture=t}e.transparent?i.alphaMode="BLEND":e.alphaTest>0&&(i.alphaMode="MASK",i.alphaCutoff=e.alphaTest),e.side===r.$EB&&(i.doubleSided=!0),""!==e.name&&(i.name=e.name),this.serializeUserData(e,i),await this._invokeAllAsync(async function(t){t.writeMaterialAsync&&await t.writeMaterialAsync(e,i)});let o=n.materials.push(i)-1;return t.materials.set(e,o),o}async processMeshAsync(e){let t;let n=this.cache,i=this.json,a=[e.geometry.uuid];if(Array.isArray(e.material))for(let t=0,n=e.material.length;t0){let t=[],r=[],i={};if(void 0!==e.morphTargetDictionary)for(let t in e.morphTargetDictionary)i[e.morphTargetDictionary[t]]=t;for(let s=0;s0&&(u.extras={},u.extras.targetNames=r)}let y=Array.isArray(e.material);if(y&&0===c.groups.length)return null;let b=!1;if(y&&null===c.index){let e=[];for(let t=0,n=c.attributes.position.count;t0&&(r.targets=p),null!==c.index){let t=this.getUID(c.index);(void 0!==w[e].start||void 0!==w[e].count)&&(t+=":"+w[e].start+":"+w[e].count),n.attributes.has(t)?r.indices=n.attributes.get(t):(r.indices=this.processAccessor(c.index,c,w[e].start,w[e].count),n.attributes.set(t,r.indices)),null===r.indices&&delete r.indices}let i=await this.processMaterialAsync(g[w[e].materialIndex]);null!==i&&(r.material=i),f.push(r)}!0===b&&c.setIndex(null),u.primitives=f,i.meshes||(i.meshes=[]),await this._invokeAllAsync(function(t){t.writeMesh&&t.writeMesh(e,u)});let k=i.meshes.push(u)-1;return n.meshes.set(l,k),k}detectMeshQuantization(e,t){let n;if(this.extensionsUsed[a])return;switch(t.array.constructor){case Int8Array:n="byte";break;case Uint8Array:n="unsigned byte";break;case Int16Array:n="short";break;case Uint16Array:n="unsigned short";break;default:return}t.normalized&&(n+=" normalized");let r=e.split("_",1)[0];i[r]&&i[r].includes(n)&&(this.extensionsUsed[a]=!0,this.extensionsRequired[a]=!0)}processCamera(e){let t=this.json;t.cameras||(t.cameras=[]);let n=e.isOrthographicCamera,i={type:n?"orthographic":"perspective"};return n?i.orthographic={xmag:2*e.right,ymag:2*e.top,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:i.perspective={aspectRatio:e.aspect,yfov:r.cj9.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},""!==e.name&&(i.name=e.type),t.cameras.push(i)-1}processAnimation(e,t){let n=this.json,i=this.nodeMap;n.animations||(n.animations=[]);let o=(e=s.Utils.mergeMorphTargetTracks(e.clone(),t)).tracks,a=[],l=[];for(let e=0;e0){let t=[];for(let r=0,i=e.children.length;r0&&(i.children=t)}await this._invokeAllAsync(function(t){t.writeNode&&t.writeNode(e,i)});let s=t.nodes.push(i)-1;return r.set(e,s),s}async processSceneAsync(e){let t=this.json,n=this.options;t.scenes||(t.scenes=[],t.scene=0);let r={};""!==e.name&&(r.name=e.name),t.scenes.push(r);let i=[];for(let t=0,r=e.children.length;t0&&(r.nodes=i),this.serializeUserData(e,r)}async processObjectsAsync(e){let t=new r.Z58;t.name="AuxScene";for(let n=0;n0&&await this.processObjectsAsync(n);for(let e=0;e0&&(s.range=e.distance)):e.isSpotLight&&(s.type="spot",e.distance>0&&(s.range=e.distance),s.spot={},s.spot.innerConeAngle=(1-e.penumbra)*e.angle,s.spot.outerConeAngle=e.angle),void 0!==e.decay&&2!==e.decay&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),e.target&&(e.target.parent!==e||0!==e.target.position.x||0!==e.target.position.y||-1!==e.target.position.z)&&console.warn("THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."),i[this.name]||(r.extensions=r.extensions||{},r.extensions[this.name]={lights:[]},i[this.name]=!0);let o=r.extensions[this.name].lights;o.push(s),t.extensions=t.extensions||{},t.extensions[this.name]={light:o.length-1}}}class b{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}async writeMaterialAsync(e,t){if(!e.isMeshBasicMaterial)return;let n=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},n[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}}class g{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||0===e.clearcoat)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.clearcoatFactor=e.clearcoat,e.clearcoatMap){let t={index:await n.processTextureAsync(e.clearcoatMap),texCoord:e.clearcoatMap.channel};n.applyTextureTransform(t,e.clearcoatMap),i.clearcoatTexture=t}if(i.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){let t={index:await n.processTextureAsync(e.clearcoatRoughnessMap),texCoord:e.clearcoatRoughnessMap.channel};n.applyTextureTransform(t,e.clearcoatRoughnessMap),i.clearcoatRoughnessTexture=t}if(e.clearcoatNormalMap){let t={index:await n.processTextureAsync(e.clearcoatNormalMap),texCoord:e.clearcoatNormalMap.channel};1!==e.clearcoatNormalScale.x&&(t.scale=e.clearcoatNormalScale.x),n.applyTextureTransform(t,e.clearcoatNormalMap),i.clearcoatNormalTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class w{constructor(e){this.writer=e,this.name="KHR_materials_dispersion"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||0===e.dispersion)return;let n=this.writer.extensionsUsed,r={};r.dispersion=e.dispersion,t.extensions=t.extensions||{},t.extensions[this.name]=r,n[this.name]=!0}}class k{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||0===e.iridescence)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.iridescenceFactor=e.iridescence,e.iridescenceMap){let t={index:await n.processTextureAsync(e.iridescenceMap),texCoord:e.iridescenceMap.channel};n.applyTextureTransform(t,e.iridescenceMap),i.iridescenceTexture=t}if(i.iridescenceIor=e.iridescenceIOR,i.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],i.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){let t={index:await n.processTextureAsync(e.iridescenceThicknessMap),texCoord:e.iridescenceThicknessMap.channel};n.applyTextureTransform(t,e.iridescenceThicknessMap),i.iridescenceThicknessTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class x{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.transmissionFactor=e.transmission,e.transmissionMap){let t={index:await n.processTextureAsync(e.transmissionMap),texCoord:e.transmissionMap.channel};n.applyTextureTransform(t,e.transmissionMap),i.transmissionTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class T{constructor(e){this.writer=e,this.name="KHR_materials_volume"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.thicknessFactor=e.thickness,e.thicknessMap){let t={index:await n.processTextureAsync(e.thicknessMap),texCoord:e.thicknessMap.channel};n.applyTextureTransform(t,e.thicknessMap),i.thicknessTexture=t}e.attenuationDistance!==1/0&&(i.attenuationDistance=e.attenuationDistance),i.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class A{constructor(e){this.writer=e,this.name="KHR_materials_ior"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||1.5===e.ior)return;let n=this.writer.extensionsUsed,r={};r.ior=e.ior,t.extensions=t.extensions||{},t.extensions[this.name]=r,n[this.name]=!0}}class P{constructor(e){this.writer=e,this.name="KHR_materials_specular"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||1===e.specularIntensity&&e.specularColor.equals(u)&&!e.specularIntensityMap&&!e.specularColorMap)return;let n=this.writer,r=n.extensionsUsed,i={};if(e.specularIntensityMap){let t={index:await n.processTextureAsync(e.specularIntensityMap),texCoord:e.specularIntensityMap.channel};n.applyTextureTransform(t,e.specularIntensityMap),i.specularTexture=t}if(e.specularColorMap){let t={index:await n.processTextureAsync(e.specularColorMap),texCoord:e.specularColorMap.channel};n.applyTextureTransform(t,e.specularColorMap),i.specularColorTexture=t}i.specularFactor=e.specularIntensity,i.specularColorFactor=e.specularColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class R{constructor(e){this.writer=e,this.name="KHR_materials_sheen"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||0==e.sheen)return;let n=this.writer,r=n.extensionsUsed,i={};if(e.sheenRoughnessMap){let t={index:await n.processTextureAsync(e.sheenRoughnessMap),texCoord:e.sheenRoughnessMap.channel};n.applyTextureTransform(t,e.sheenRoughnessMap),i.sheenRoughnessTexture=t}if(e.sheenColorMap){let t={index:await n.processTextureAsync(e.sheenColorMap),texCoord:e.sheenColorMap.channel};n.applyTextureTransform(t,e.sheenColorMap),i.sheenColorTexture=t}i.sheenRoughnessFactor=e.sheenRoughness,i.sheenColorFactor=e.sheenColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class S{constructor(e){this.writer=e,this.name="KHR_materials_anisotropy"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||0==e.anisotropy)return;let n=this.writer,r=n.extensionsUsed,i={};if(e.anisotropyMap){let t={index:await n.processTextureAsync(e.anisotropyMap)};n.applyTextureTransform(t,e.anisotropyMap),i.anisotropyTexture=t}i.anisotropyStrength=e.anisotropy,i.anisotropyRotation=e.anisotropyRotation,t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class E{constructor(e){this.writer=e,this.name="KHR_materials_emissive_strength"}async writeMaterialAsync(e,t){if(!e.isMeshStandardMaterial||1===e.emissiveIntensity)return;let n=this.writer.extensionsUsed,r={};r.emissiveStrength=e.emissiveIntensity,t.extensions=t.extensions||{},t.extensions[this.name]=r,n[this.name]=!0}}class O{constructor(e){this.writer=e,this.name="EXT_materials_bump"}async writeMaterialAsync(e,t){if(!e.isMeshStandardMaterial||1===e.bumpScale&&!e.bumpMap)return;let n=this.writer,r=n.extensionsUsed,i={};if(e.bumpMap){let t={index:await n.processTextureAsync(e.bumpMap),texCoord:e.bumpMap.channel};n.applyTextureTransform(t,e.bumpMap),i.bumpTexture=t}i.bumpFactor=e.bumpScale,t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class M{constructor(e){this.writer=e,this.name="EXT_mesh_gpu_instancing"}writeNode(e,t){if(!e.isInstancedMesh)return;let n=this.writer,i=new Float32Array(3*e.count),s=new Float32Array(4*e.count),o=new Float32Array(3*e.count),a=new r.kn4,l=new r.Pq0,c=new r.PTz,u=new r.Pq0;for(let t=0;tMath.abs(e.times[0]-t))return 0;i[0]=t,i.set(e.times,1),s.set(o.evaluate(t),0),s.set(e.values,r),n=0}else if(t>e.times[e.times.length-1]){if(.001>Math.abs(e.times[e.times.length-1]-t))return e.times.length-1;i[i.length-1]=t,i.set(e.times,0),s.set(e.values,0),s.set(o.evaluate(t),e.values.length),n=i.length-1}else for(let a=0;aMath.abs(e.times[a]-t))return a;if(e.times[a]t){i.set(e.times.slice(0,a+1),0),i[a+1]=t,i.set(e.times.slice(a+1),a+2),s.set(e.values.slice(0,(a+1)*r),0),s.set(o.evaluate(t),(a+1)*r),s.set(e.values.slice((a+1)*r),(a+2)*r),n=a+1;break}}return e.times=i,e.values=s,n},mergeMorphTargetTracks:function(e,t){let n=[],i={},s=e.tracks;for(let e=0;e=2.0 are supported."));return}let l=new ex(i,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e=0&&void 0===o[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}l.setExtensions(s),l.setPlugins(o),l.parse(n,r)}parseAsync(e,t){let n=this;return new Promise(function(r,i){n.parse(e,t,r,i)})}}function C(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}let j={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class B{constructor(e){this.parser=e,this.name=j.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n=0))return null;throw Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures")}return t.loadTextureImage(e,i.source,s)}}class W{constructor(e){this.parser=e,this.name=j.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let s=i.extensions[t],o=r.images[s.source],a=n.textureLoader;if(o.uri){let e=n.options.manager.getHandler(o.uri);null!==e&&(a=e)}return this.detectSupport().then(function(i){if(i)return n.loadTextureImage(e,s.source,a);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){let t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}})),this.isSupported}}class Q{constructor(e){this.parser=e,this.name=j.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let s=i.extensions[t],o=r.images[s.source],a=n.textureLoader;if(o.uri){let e=n.options.manager.getHandler(o.uri);null!==e&&(a=e)}return this.detectSupport().then(function(i){if(i)return n.loadTextureImage(e,s.source,a);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){let t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(1===t.height)}})),this.isSupported}}class Z{constructor(e){this.name=j.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(!n.extensions||!n.extensions[this.name])return null;{let e=n.extensions[this.name],r=this.parser.getDependency("buffer",e.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(!(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0))return null;throw Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files")}return r.then(function(t){let n=e.byteOffset||0,r=e.byteLength||0,s=e.count,o=e.byteStride,a=new Uint8Array(t,n,r);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(s,o,a,e.mode,e.filter).then(function(e){return e.buffer}):i.ready.then(function(){let t=new ArrayBuffer(s*o);return i.decodeGltfBuffer(new Uint8Array(t),s,o,a,e.mode,e.filter),t})})}}}class J{constructor(e){this.name=j.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||void 0===n.mesh)return null;for(let e of t.meshes[n.mesh].primitives)if(e.mode!==el.TRIANGLES&&e.mode!==el.TRIANGLE_STRIP&&e.mode!==el.TRIANGLE_FAN&&void 0!==e.mode)return null;let i=n.extensions[this.name].attributes,s=[],o={};for(let e in i)s.push(this.parser.getDependency("accessor",i[e]).then(t=>(o[e]=t,o[e])));return s.length<1?null:(s.push(this.parser.createNodeMesh(e)),Promise.all(s).then(e=>{let t=e.pop(),n=t.isGroup?t.children:[t],i=e[0].count,s=[];for(let e of n){let t=new r.kn4,n=new r.Pq0,a=new r.PTz,l=new r.Pq0(1,1,1),c=new r.ZLX(e.geometry,e.material,i);for(let e=0;e-1)?e.match(/Firefox\/([0-9]+)\./)[1]:-1}"undefined"==typeof createImageBitmap||n&&i<17||s&&o<98?this.textureLoader=new r.Tap(this.options.manager):this.textureLoader=new r.Kzg(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new r.Y9S(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,r=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(e){return e._markDefs&&e._markDefs()}),Promise.all(this._invokeAll(function(e){return e.beforeRoot&&e.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(t){let s={scene:t[0][r.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:r.asset,parser:n,userData:{}};return ey(i,s,r),eb(s,r),Promise.all(n._invokeAll(function(e){return e.afterRoot&&e.afterRoot(s)})).then(function(){for(let e of s.scenes)e.updateMatrixWorld();e(s)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,r=t.length;n{let n=this.associations.get(e);for(let[r,s]of(null!=n&&this.associations.set(t,n),e.children.entries()))i(s,t.children[r])};return i(n,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n=2&&o.setY(t,f[e*l+1]),l>=3&&o.setZ(t,f[e*l+2]),l>=4&&o.setW(t,f[e*l+3]),l>=5)throw Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}o.normalized=d}return o})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e].source,i=t.images[r],s=this.textureLoader;if(i.uri){let e=n.manager.getHandler(i.uri);null!==e&&(s=e)}return this.loadTextureImage(e,r,s)}loadTextureImage(e,t,n){let i=this,s=this.json,o=s.textures[e],a=s.images[t],l=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[l])return this.textureCache[l];let c=this.loadImageSource(t,n).then(function(t){t.flipY=!1,t.name=o.name||a.name||"",""===t.name&&"string"==typeof a.uri&&!1===a.uri.startsWith("data:image/")&&(t.name=a.uri);let n=(s.samplers||{})[o.sampler]||{};return t.magFilter=eu[n.magFilter]||r.k6q,t.minFilter=eu[n.minFilter]||r.$_I,t.wrapS=eh[n.wrapS]||r.GJx,t.wrapT=eh[n.wrapT]||r.GJx,t.generateMipmaps=!t.isCompressedTexture&&t.minFilter!==r.hxR&&t.minFilter!==r.k6q,i.associations.set(t,{textures:e}),t}).catch(function(){return null});return this.textureCache[l]=c,c}loadImageSource(e,t){let n=this.json,i=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then(e=>e.clone());let s=n.images[e],o=self.URL||self.webkitURL,a=s.uri||"",l=!1;if(void 0!==s.bufferView)a=this.getDependency("bufferView",s.bufferView).then(function(e){l=!0;let t=new Blob([e],{type:s.mimeType});return a=o.createObjectURL(t)});else if(void 0===s.uri)throw Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let c=Promise.resolve(a).then(function(e){return new Promise(function(n,s){let o=n;!0===t.isImageBitmapLoader&&(o=function(e){let t=new r.gPd(e);t.needsUpdate=!0,n(t)}),t.load(r.r6x.resolveURL(e,i.path),o,void 0,s)})}).then(function(e){var t;return!0===l&&o.revokeObjectURL(a),eb(e,s),e.userData.mimeType=s.mimeType||((t=s.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":t.search(/\.ktx2($|\?)/i)>0||0===t.search(/^data\:image\/ktx2/)?"image/ktx2":"image/png"),e}).catch(function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),e});return this.sourceCache[e]=c,c}assignTexture(e,t,n,r){let i=this;return this.getDependency("texture",n.index).then(function(s){if(!s)return null;if(void 0!==n.texCoord&&n.texCoord>0&&((s=s.clone()).channel=n.texCoord),i.extensions[j.KHR_TEXTURE_TRANSFORM]){let e=void 0!==n.extensions?n.extensions[j.KHR_TEXTURE_TRANSFORM]:void 0;if(e){let t=i.associations.get(s);s=i.extensions[j.KHR_TEXTURE_TRANSFORM].extendTexture(s,e),i.associations.set(s,t)}}return void 0!==r&&(s.colorSpace=r),e[t]=s,s})}assignFinalMaterial(e){let t=e.geometry,n=e.material,i=void 0===t.attributes.tangent,s=void 0!==t.attributes.color,o=void 0===t.attributes.normal;if(e.isPoints){let e="PointsMaterial:"+n.uuid,t=this.cache.get(e);t||(t=new r.BH$,r.imn.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){let e="LineBasicMaterial:"+n.uuid,t=this.cache.get(e);t||(t=new r.mrM,r.imn.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,this.cache.add(e,t)),n=t}if(i||s||o){let e="ClonedMaterial:"+n.uuid+":";i&&(e+="derivative-tangents:"),s&&(e+="vertex-colors:"),o&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=n.clone(),s&&(t.vertexColors=!0),o&&(t.flatShading=!0),i&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}e.material=n}getMaterialType(){return r._4j}loadMaterial(e){let t;let n=this,i=this.json,s=this.extensions,o=i.materials[e],a={},l=o.extensions||{},c=[];if(l[j.KHR_MATERIALS_UNLIT]){let e=s[j.KHR_MATERIALS_UNLIT];t=e.getMaterialType(),c.push(e.extendParams(a,o,n))}else{let i=o.pbrMetallicRoughness||{};if(a.color=new r.Q1f(1,1,1),a.opacity=1,Array.isArray(i.baseColorFactor)){let e=i.baseColorFactor;a.color.setRGB(e[0],e[1],e[2],r.Zr2),a.opacity=e[3]}void 0!==i.baseColorTexture&&c.push(n.assignTexture(a,"map",i.baseColorTexture,r.er$)),a.metalness=void 0!==i.metallicFactor?i.metallicFactor:1,a.roughness=void 0!==i.roughnessFactor?i.roughnessFactor:1,void 0!==i.metallicRoughnessTexture&&(c.push(n.assignTexture(a,"metalnessMap",i.metallicRoughnessTexture)),c.push(n.assignTexture(a,"roughnessMap",i.metallicRoughnessTexture))),t=this._invokeOne(function(t){return t.getMaterialType&&t.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,a)})))}!0===o.doubleSided&&(a.side=r.$EB);let u=o.alphaMode||em.OPAQUE;if(u===em.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,u===em.MASK&&(a.alphaTest=void 0!==o.alphaCutoff?o.alphaCutoff:.5)),void 0!==o.normalTexture&&t!==r.V9B&&(c.push(n.assignTexture(a,"normalMap",o.normalTexture)),a.normalScale=new r.I9Y(1,1),void 0!==o.normalTexture.scale)){let e=o.normalTexture.scale;a.normalScale.set(e,e)}if(void 0!==o.occlusionTexture&&t!==r.V9B&&(c.push(n.assignTexture(a,"aoMap",o.occlusionTexture)),void 0!==o.occlusionTexture.strength&&(a.aoMapIntensity=o.occlusionTexture.strength)),void 0!==o.emissiveFactor&&t!==r.V9B){let e=o.emissiveFactor;a.emissive=new r.Q1f().setRGB(e[0],e[1],e[2],r.Zr2)}return void 0!==o.emissiveTexture&&t!==r.V9B&&c.push(n.assignTexture(a,"emissiveMap",o.emissiveTexture,r.er$)),Promise.all(c).then(function(){let r=new t(a);return o.name&&(r.name=o.name),eb(r,o),n.associations.set(r,{materials:e}),o.extensions&&ey(s,r,o),r})}createUniqueName(e){let t=r.Nwf.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,n=this.extensions,i=this.primitiveCache,s=[];for(let o=0,a=e.length;o0&&function(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let n=0,r=t.weights.length;n1?new r.YJl:1===t.length?t[0]:new r.B69)!==t[0])for(let e=0,n=t.length;e{let t=new Map;for(let[e,n]of i.associations)(e instanceof r.imn||e instanceof r.gPd)&&t.set(e,n);return e.traverse(e=>{let n=i.associations.get(e);null!=n&&t.set(e,n)}),t})(s),s})}_createAnimationTracks(e,t,n,i,s){let o;let a=[],l=e.name?e.name:e.uuid,c=[];switch(ed[s.path]===ed.weights?e.traverse(function(e){e.morphTargetInfluences&&c.push(e.name?e.name:e.uuid)}):c.push(l),ed[s.path]){case ed.weights:o=r.Hit;break;case ed.rotation:o=r.MBL;break;case ed.position:case ed.scale:o=r.RiT;break;default:o=1===n.itemSize?r.Hit:r.RiT}let u=void 0!==i.interpolation?ev[i.interpolation]:r.PJ3,h=this._getArrayFromAccessor(n);for(let e=0,n=c.length;e{n.d(t,{m:()=>c});var r=n("./src/model/ball.ts"),i=n("./src/view/tablegeometry.ts"),s=n("./node_modules/three/build/three.module.js"),o=n("./src/utils/utils.ts"),a=n("./src/model/physics/constants.ts");function l(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var c=/*#__PURE__*/function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t)}return e=[{key:"jitter",value:function(e){return(0,o.ld)(e.clone().add(new s.Pq0(t.noise*(Math.random()-.5),t.noise*(Math.random()-.5),0)))}},{key:"cueBall",value:function(e){return new r.c(t.jitter(e),0xfaebd7)}},{key:"diamond",value:function(){var e=new s.Pq0(i.P.tableX/2,0,0),n=[];return n.push(t.cueBall(t.spot)),n.push(new r.c(t.jitter(e),0xe0de36)),e.add(t.diagonal),n.push(new r.c(t.jitter(e),0xff9d00)),e.sub(t.across),n.push(new r.c(t.jitter(e),5380369)),e.add(t.diagonal),n.push(new r.c(t.jitter(e),5853696)),e.sub(t.across),n.push(new r.c(t.jitter(e),0xff0000)),e.addScaledVector(t.across,2),n.push(new r.c(t.jitter(e),328965)),e.add(t.diagonal).sub(t.across),n.push(new r.c(t.jitter(e),685250)),e.sub(t.across),n.push(new r.c(t.jitter(e),553728)),e.add(t.diagonal),n.push(new r.c(t.jitter(e),4063388)),n}},{key:"triangle",value:function(){var e=t.trianglePositions(),n=t.cueBall(t.spot),i=e.map(function(e){return new r.c(t.jitter(e))});return i.unshift(n),i.slice(0,5)}},{key:"trianglePositions",value:function(){var e=[],t=new s.Pq0(i.P.X/2,0,0);return e.push((0,o.t6)(t)),t.add(this.diagonal),e.push((0,o.t6)(t)),t.sub(this.across),e.push((0,o.t6)(t)),t.add(this.diagonal),e.push((0,o.t6)(t)),t.sub(this.across),e.push((0,o.t6)(t)),t.addScaledVector(this.across,2),e.push((0,o.t6)(t)),t.add(this.diagonal),e.push((0,o.t6)(t)),t.sub(this.across),e.push((0,o.t6)(t)),t.sub(this.across),e.push((0,o.t6)(t)),t.sub(this.across),e.push((0,o.t6)(t)),t.add(this.diagonal).sub(this.across),e.push((0,o.t6)(t)),t.add(this.across),e.push((0,o.t6)(t)),t.add(this.across),e.push((0,o.t6)(t)),t.add(this.across),e.push((0,o.t6)(t)),t.add(this.across),e.push((0,o.t6)(t)),e}},{key:"rerack",value:function(e,n){var i=t.trianglePositions(),s=i.shift();n.balls.filter(function(e){return e!==n.cueball}).filter(function(t){return t!==e}).forEach(function(e){e.pos.copy(t.jitter(i.shift())),e.state=r.U.Stationary}),n.overlapsAny(e.pos,e)&&e.pos.copy(s),n.overlapsAny(n.cueball.pos)&&n.cueball.pos.copy(t.spot)}},{key:"three",value:function(){var e=[],n=i.P.X/2,o=i.P.Y/4;return e.push(t.cueBall(t.jitter(new s.Pq0(-n,-o,0)))),e.push(new r.c(t.jitter(new s.Pq0(-n,0,0)),0xe0de36)),e.push(new r.c(t.jitter(new s.Pq0(n,0,0)),0xff0000)),e}},{key:"snooker",value:function(){var e=[],n=i.P.Y/4;e.push(t.cueBall(t.jitter(new s.Pq0(t.baulk,-(.5*n),0))));var o=t.snookerColourPositions();return e.push(new r.c(t.jitter(o[0]),0xeede36)),e.push(new r.c(t.jitter(o[1]),824932)),e.push(new r.c(t.jitter(o[2]),0xbd723a)),e.push(new r.c(t.jitter(o[3]),558062)),e.push(new r.c(t.jitter(o[4]),0xffaacc)),e.push(new r.c(t.jitter(o[5]),65793)),t.trianglePositions().slice(0,15).forEach(function(n){e.push(new r.c(t.jitter(n.add(t.down)),0xee0000))}),e}},{key:"snookerColourPositions",value:function(){var e=i.P.X/2,n=i.P.X-2*i.P.X/11,r=[];return r.push(new s.Pq0(t.baulk,-t.sixth,0)),r.push(new s.Pq0(t.baulk,t.sixth,0)),r.push(new s.Pq0(t.baulk,0,0)),r.push(new s.Pq0(0,0,0)),r.push(new s.Pq0(e,0,0)),r.push(new s.Pq0(n,0,0)),r}}],function(e,t){for(var n=0;n{n.d(t,{k:()=>a});var r=n("./src/model/ball.ts"),i=n("./src/view/tablegeometry.ts"),s=n("./src/model/physics/constants.ts"),o=n("./src/utils/rack.ts"),a=/*#__PURE__*/function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t)}return e=[{key:"respot",value:function(e,n){var i=o.m.snookerColourPositions();return i.push(i[e.id-1]),i.reverse(),i.some(function(t){return!n.overlapsAny(t,e)&&(e.pos.copy(t),e.state=r.U.Stationary,!0)})||t.respotBehind(i[0],e,n),e}},{key:"respotBehind",value:function(e,t,n){for(var o=e.clone();o.x-i.P.tableX&&n.overlapsAny(o,t);)o.x-=s.R/8;t.pos.copy(o),t.state=r.U.Stationary}},{key:"closest",value:function(e,t){var n=t.filter(function(e){return e.onTable()}).filter(function(t){return t!==e});if(0!==n.length){var r=function(t){return e.pos.distanceTo(t.pos)};return n.reduce(function(e,t){return r(e){n.d(t,{Dz:()=>p,KM:()=>l,ld:()=>v,rq:()=>f,t6:()=>o,up:()=>s,v_:()=>i,xb:()=>u});var r=n("./node_modules/three/build/three.module.js"),i=new r.Pq0(0,0,0),s=new r.Pq0(0,0,1);function o(e){return new r.Pq0(e.x,e.y,e.z)}var a=new r.Pq0;function l(e){return a.copy(s).cross(e)}var c=new r.Pq0;function u(e){return c.copy(e).normalize()}var h=new r.Pq0;function f(e,t){return 0>=h.copy(e).add(t).dot(e)}function p(e){return new r.Pq0(1,0,0).applyAxisAngle(s,e)}function d(e){return Math.sign(e)*Math.floor((Math.abs(e)+Number.EPSILON)*1e4)/1e4}function v(e){return e.x=d(e.x),e.y=d(e.y),e.z=d(e.z),e}},"./src/view/assets.ts":(e,t,n)=>{n.d(t,{s:()=>m});var r=n("./src/controller/rules/rulefactory.ts"),i=n("./src/utils/gltf.ts"),s=n("./node_modules/three/build/three.module.js");function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var a=/*#__PURE__*/function(){var e;function t(e){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),o(this,"listener",void 0),o(this,"audioLoader",void 0),o(this,"ballcollision",void 0),o(this,"cue",void 0),o(this,"cushion",void 0),o(this,"pot",void 0),o(this,"success",void 0),o(this,"lastOutcomeTime",0),o(this,"loadAssets",void 0),this.loadAssets=e,e&&(this.listener=new s.Pf$,this.audioLoader=new s.Am1,this.ballcollision=new s.fP5(this.listener),this.load("sounds/ballcollision.ogg",this.ballcollision),this.cue=new s.fP5(this.listener),this.load("sounds/cue.ogg",this.cue),this.cushion=new s.fP5(this.listener),this.load("sounds/cushion.ogg",this.cushion),this.pot=new s.fP5(this.listener),this.load("sounds/pot.ogg",this.pot),this.success=new s.fP5(this.listener),this.load("sounds/success.ogg",this.success))}return e=[{key:"addCameraToListener",value:function(e){e.add(this.listener)}},{key:"load",value:function(e,t){this.audioLoader.load(e,function(e){t.setBuffer(e),t.setLoop(!1)},function(e){},function(e){})}},{key:"play",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(this.loadAssets){var r,i,o=s.UtX.getContext();if((null==o?void 0:o.state)==="suspended"){(null===(i=navigator)||void 0===i?void 0:null===(r=i.userActivation)||void 0===r?void 0:r.hasBeenActive)&&o.resume();return}e.setVolume(t),e.isPlaying&&e.stop(),e.play(s.cj9.randFloat(0,.01)),e.setDetune(n)}}},{key:"outcomeToSound",value:function(e){"Collision"===e.type&&this.play(this.ballcollision,e.incidentSpeed/80,5*e.incidentSpeed),"Pot"===e.type&&this.play(this.pot,e.incidentSpeed/10,-1e3+10*e.incidentSpeed),"Cushion"===e.type&&this.play(this.cushion,e.incidentSpeed/70),"Hit"===e.type&&this.play(this.cue,e.incidentSpeed/30)}},{key:"processOutcomes",value:function(e){var t=this;e.every(function(e){return!(e.timestamp>t.lastOutcomeTime)||(t.lastOutcomeTime=e.timestamp,t.outcomeToSound(e),!1)})}},{key:"playNotify",value:function(){this.play(this.pot,1)}},{key:"playSuccess",value:function(e){this.play(this.success,.1,100*e-2200)}}],function(e,t){for(var n=0;n2&&void 0!==arguments[2]?arguments[2]:this.cloth;this.cylinder(e.pos,e.radius,.75*u.R/.5,t,n).position.setZ(-(.25*u.R)/.5/2)}},{key:"cylinder",value:function(e,t,n,r,i){var o=new s.Ho_(t,t,n,16),a=new s.eaF(o,i);return a.position.copy(e),a.geometry.applyMatrix4(new s.kn4().identity().makeRotationAxis(new s.Pq0(1,0,0),Math.PI/2)),r.add(a),a}},{key:"addCushions",value:function(e,t){var n=10*u.R/.5;this.plane(new s.Pq0(0,0,-u.R-n/2),2*l.P.X,2*l.P.Y,n,e,this.cloth);var r=1*u.R/.5,i=.75*u.R/.5,o=-(.25*u.R)/.5/2,a=l.P.X,h=l.P.Y,f=Math.abs(c.f.pockets.pocketNW.knuckleNE.pos.x-c.f.pockets.pocketN.knuckleNW.pos.x),p=Math.abs(c.f.pockets.pocketNW.knuckleSW.pos.y-c.f.pockets.pocketSW.knuckleNW.pos.y);t||(f=2*l.P.Y,p=2*l.P.Y+4*u.R),this.plane(new s.Pq0(a+r/2,0,o),r,p,i,e),this.plane(new s.Pq0(-a-r/2,0,o),r,p,i,e),this.plane(new s.Pq0(-a/2,h+r/2,o),f,r,i,e),this.plane(new s.Pq0(-a/2,-h-r/2,o),f,r,i,e),this.plane(new s.Pq0(a/2,h+r/2,o),f,r,i,e),this.plane(new s.Pq0(a/2,-h-r/2,o),f,r,i,e)}},{key:"plane",value:function(e,t,n,r,i){var o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:this.cushion,a=new s.iNn(t,n,r),l=new s.eaF(a,o);l.receiveShadow=!0,l.position.copy(e),i.add(l)}}],function(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:"",t=new n(e);return t.creatLocal(),t}}],e&&d(n.prototype,e),t&&d(n,t),n}()},"./src/view/cameratop.ts":(e,t,n)=>{n.d(t,{v:()=>a});var r=n("./node_modules/three/build/three.module.js"),i=n("./src/view/tablegeometry.ts"),s=n("./src/model/physics/constants.ts");function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var a=/*#__PURE__*/function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t)}return e=[{key:"viewPoint",value:function(e,n){var o=t.zoomFactor/(2*Math.tan(n*Math.PI/360));if(e>this.portrait){var a=e>t.aspectLimit?2.75*i.P.tableY:2.4*i.P.tableX/e;return new r.Pq0(0,-.01*s.R,o*a)}var l=e>1/t.aspectLimit?4.9*i.P.tableY:1.35*i.P.tableX/e;return new r.Pq0(-.01*s.R,0,o*l)}}],function(e,t){for(var n=0;n{n.d(t,{s:()=>f});var r=n("./src/view/tablegeometry.ts"),i=n("./src/utils/utils.ts"),s=n("./src/events/aimevent.ts"),o=n("./src/model/ball.ts"),a=n("./src/model/physics/physics.ts"),l=n("./src/view/cuemesh.ts"),c=n("./node_modules/three/build/three.module.js"),u=n("./src/model/physics/constants.ts");function h(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var f=/*#__PURE__*/function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),h(this,"mesh",void 0),h(this,"helperMesh",void 0),h(this,"placerMesh",void 0),h(this,"offCenterLimit",.3),h(this,"maxPower",150*u.R),h(this,"t",0),h(this,"aimInputs",void 0),h(this,"aim",new s.w),h(this,"length",1*r.P.tableX),this.mesh=l.l.createCue(.05*u.R/.5,.15*u.R/.5,this.length),this.helperMesh=l.l.createHelper(),this.placerMesh=l.l.createPlacer()}return e=[{key:"rotateAim",value:function(e,t){this.aim.angle=this.aim.angle+e,this.mesh.rotation.z=this.aim.angle,this.helperMesh.rotation.z=this.aim.angle,this.aimInputs.showOverlap(),this.avoidCueTouchingOtherBall(t)}},{key:"adjustPower",value:function(e){this.aim.power=Math.min(this.maxPower,this.aim.power+e),this.updateAimInput()}},{key:"setPower",value:function(e){this.aim.power=e*this.maxPower}},{key:"hit",value:function(e){var t=this.aim;this.t=0,e.state=o.U.Sliding,e.vel.copy((0,i.Dz)(t.angle).multiplyScalar(t.power)),e.rvel.copy((0,a.t6)(t.offset,e.vel))}},{key:"aimAtNext",value:function(e,t){if(t){var n=(0,i.xb)(t.pos.clone().sub(e.pos));this.aim.angle=Math.atan2(n.y,n.x)}}},{key:"adjustSpin",value:function(e,t){var n=this.aim.offset.clone().clone().add(e);this.setSpin(n,t)}},{key:"setSpin",value:function(e,t){e.length()>this.offCenterLimit&&e.normalize().multiplyScalar(this.offCenterLimit),this.aim.offset.copy(e),this.avoidCueTouchingOtherBall(t),this.updateAimInput()}},{key:"avoidCueTouchingOtherBall",value:function(e){for(var t=0;t++<20&&this.intersectsAnything(e);)this.aim.offset.y+=.1,this.aim.offset.length()>this.offCenterLimit&&this.aim.offset.normalize().multiplyScalar(this.offCenterLimit);t>1&&this.updateAimInput()}},{key:"updateAimInput",value:function(){var e,t,n;null===(e=this.aimInputs)||void 0===e||e.updateVisualState(this.aim.offset.x,this.aim.offset.y),null===(t=this.aimInputs)||void 0===t||t.updatePowerSlider(this.aim.power/this.maxPower),null===(n=this.aimInputs)||void 0===n||n.showOverlap()}},{key:"moveTo",value:function(e){this.aim.pos.copy(e),this.mesh.rotation.z=this.aim.angle,this.helperMesh.rotation.z=this.aim.angle;var t=this.spinOffset(),n=(Math.sin(this.t+Math.PI/2)-1)*2*u.R*(this.aim.power/this.maxPower),r=(0,i.Dz)(this.aim.angle).clone().multiplyScalar(n);this.mesh.position.copy(e.clone().add(t).add(r)),this.helperMesh.position.copy(e),this.placerMesh.position.copy(e),this.placerMesh.rotation.z=this.t}},{key:"update",value:function(e){this.t+=e,this.moveTo(this.aim.pos)}},{key:"placeBallMode",value:function(){this.mesh.visible=!1,this.placerMesh.visible=!0,this.aim.angle=0}},{key:"aimMode",value:function(){this.mesh.visible=!0,this.placerMesh.visible=!1}},{key:"spinOffset",value:function(){return(0,i.KM)((0,i.Dz)(this.aim.angle)).multiplyScalar(2*this.aim.offset.x*u.R).setZ(2*this.aim.offset.y*u.R)}},{key:"intersectsAnything",value:function(e){var t=this.spinOffset(),n=e.cueball.pos.clone().add(t),r=(0,i.xb)((0,i.Dz)(this.aim.angle+Math.PI).setZ(.1)),s=new c.tBo(n,r),o=e.balls.map(function(e){return e.ballmesh.mesh});return e.mesh&&o.push(e.mesh),s.intersectObjects(o,!0).length>0}},{key:"showHelper",value:function(e){this.helperMesh.visible=e}},{key:"toggleHelper",value:function(){this.showHelper(!this.helperMesh.visible)}}],function(e,t){for(var n=0;n{n.d(t,{l:()=>a});var r=n("./src/model/physics/constants.ts"),i=n("./src/utils/utils.ts"),s=n("./node_modules/three/build/three.module.js");function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var a=/*#__PURE__*/function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t)}return e=[{key:"indicateValid",value:function(e){t.placermaterial.color.setHex(e?0xccffcc:0xff0000)}},{key:"createHelper",value:function(){var e=new s.Ho_(r.R,r.R,30*r.R/.5,12,1,!0),t=new s.eaF(e,this.helpermaterial);return t.geometry.applyMatrix4(new s.kn4().identity().makeRotationAxis(i.up,-Math.PI/2)).applyMatrix4(new s.kn4().identity().makeTranslation(15*r.R/.5,0,-(.01*r.R)/.5)),t.visible=!1,t.renderOrder=-1,t.material.depthTest=!1,t}},{key:"createPlacer",value:function(){var e=new s.Ho_(.01*r.R/.5,r.R,r.R,4),n=new s.eaF(e,t.placermaterial);return n.geometry.applyMatrix4(new s.kn4().identity().makeRotationAxis(new s.Pq0(1,0,0),-Math.PI/2)).applyMatrix4(new s.kn4().identity().makeTranslation(0,0,.7*r.R/.5)),n.visible=!1,n}},{key:"createCue",value:function(e,n,o){var a=new s.Ho_(e,n,o,11),l=new s.eaF(a,t.material);return l.castShadow=!1,l.geometry.applyMatrix4(new s.kn4().identity().makeRotationAxis(new s.Pq0(1,0,0),-.17)).applyMatrix4(new s.kn4().identity().makeRotationAxis(i.up,-Math.PI/2)).applyMatrix4(new s.kn4().identity().makeTranslation(-o/2-r.R,0,o/2*.16918234906699603+.25*r.R)),l}}],function(e,t){for(var n=0;n{n.d(t,{f:()=>c});var r=n("./node_modules/three/build/three.module.js"),i=n("./src/model/physics/knuckle.ts"),s=n("./src/model/physics/pocket.ts"),o=n("./src/view/tablegeometry.ts"),a=n("./src/model/physics/constants.ts");function l(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var c=/*#__PURE__*/function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t)}return e=[{key:"scaleToRadius",value:function(e){t.PX=o.P.tableX+1.6*e,t.PY=o.P.tableY+1.6*e,t.knuckleInset=1.6*e/.5,t.knuckleRadius=.31*e/.5,t.middleKnuckleInset=1.385*e/.5,t.middleKnuckleRadius=.2*e/.5,t.cornerRadius=1.1*e/.5,t.middleRadius=.9*e/.5,t.pocketLayout(e),t.enumerateCenters(),t.enumerateKnuckles()}},{key:"enumerateKnuckles",value:function(){t.knuckles=[t.pockets.pocketNW.knuckleNE,t.pockets.pocketNW.knuckleSW,t.pockets.pocketN.knuckleNW,t.pockets.pocketN.knuckleNE,t.pockets.pocketS.knuckleSW,t.pockets.pocketS.knuckleSE,t.pockets.pocketNE.knuckleNW,t.pockets.pocketNE.knuckleSE,t.pockets.pocketSE.knuckleNE,t.pockets.pocketSE.knuckleSW,t.pockets.pocketSW.knuckleSE,t.pockets.pocketSW.knuckleNW]}},{key:"enumerateCenters",value:function(){t.pocketCenters=[t.pockets.pocketNW.pocket,t.pockets.pocketSW.pocket,t.pockets.pocketN.pocket,t.pockets.pocketS.pocket,t.pockets.pocketNE.pocket,t.pockets.pocketSE.pocket]}},{key:"pocketLayout",value:function(e){t.pockets={pocketNW:{pocket:new s.Z(new r.Pq0(-t.PX,t.PY,0),t.cornerRadius),knuckleNE:new i.O(new r.Pq0(-o.P.X+t.knuckleInset,o.P.Y+t.knuckleRadius,0),t.knuckleRadius),knuckleSW:new i.O(new r.Pq0(-o.P.X-t.knuckleRadius,o.P.Y-t.knuckleInset,0),t.knuckleRadius)},pocketN:{pocket:new s.Z(new r.Pq0(0,t.PY+.7*e/.5,0),t.middleRadius),knuckleNE:new i.O(new r.Pq0(t.middleKnuckleInset,o.P.Y+t.middleKnuckleRadius,0),t.middleKnuckleRadius),knuckleNW:new i.O(new r.Pq0(-t.middleKnuckleInset,o.P.Y+t.middleKnuckleRadius,0),t.middleKnuckleRadius)},pocketS:{pocket:new s.Z(new r.Pq0(0,-t.PY-.7*e/.5,0),t.middleRadius),knuckleSE:new i.O(new r.Pq0(t.middleKnuckleInset,-o.P.Y-t.middleKnuckleRadius,0),t.middleKnuckleRadius),knuckleSW:new i.O(new r.Pq0(-t.middleKnuckleInset,-o.P.Y-t.middleKnuckleRadius,0),t.middleKnuckleRadius)},pocketNE:{pocket:new s.Z(new r.Pq0(t.PX,t.PY,0),t.cornerRadius),knuckleNW:new i.O(new r.Pq0(o.P.X-t.knuckleInset,o.P.Y+t.knuckleRadius,0),t.knuckleRadius),knuckleSE:new i.O(new r.Pq0(o.P.X+t.knuckleRadius,o.P.Y-t.knuckleInset,0),t.knuckleRadius)},pocketSE:{pocket:new s.Z(new r.Pq0(t.PX,-t.PY,0),t.cornerRadius),knuckleNE:new i.O(new r.Pq0(o.P.X+t.knuckleRadius,-o.P.Y+t.knuckleInset,0),t.knuckleRadius),knuckleSW:new i.O(new r.Pq0(o.P.X-t.knuckleInset,-o.P.Y-t.knuckleRadius,0),t.knuckleRadius)},pocketSW:{pocket:new s.Z(new r.Pq0(-t.PX,-t.PY,0),t.cornerRadius),knuckleSE:new i.O(new r.Pq0(-o.P.X+t.knuckleInset,-o.P.Y-t.knuckleRadius,0),t.knuckleRadius),knuckleNW:new i.O(new r.Pq0(-o.P.X-t.knuckleRadius,-o.P.Y+t.knuckleInset,0),t.knuckleRadius)}}}}],function(e,t){for(var n=0;n{n.d(t,{r:()=>s});var r=n("./src/model/physics/constants.ts");function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var s=/*#__PURE__*/function(){var e;function t(e){var n,s;!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),i(this,"style",void 0),i(this,"notify",void 0),this.notify=null!=e?e:function(){},this.style=null!==(s=null===(n=document.getElementById("constants"))||void 0===n?void 0:n.style)&&void 0!==s?s:{},this.initialiseSlider("R",r.R,r.jG),this.initialiseSlider("m",r.m,r.Qg),this.initialiseSlider("e",r.e,r.cM),this.initialiseSlider("mu",r.mu,r.xO),this.initialiseSlider("muS",r.gf,r.Ys),this.initialiseSlider("muC",r.gT,r.kM),this.initialiseSlider("rho",r.kL,r.Wv)}return e=[{key:"toggleVisibility",value:function(){this.style.visibility="visible"===this.style.visibility?"hidden":"visible"}},{key:"getInputElement",value:function(e){var t;return null!==(t=document.getElementById(e))&&void 0!==t?t:{}}},{key:"initialiseSlider",value:function(e,t,n){var r=this,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,s=this.getInputElement(e);s.step="0.001",s.min="0.01",s.max="".concat(i),s.value=t,this.showValue(e,t),s.oninput=function(t){var i=parseFloat(t.target.value);n(i),r.showValue(e,i),r.notify()}}},{key:"showValue",value:function(e,t){var n=document.querySelector("label[for=".concat(e,"]"));n&&(n.innerHTML="".concat(e,"=").concat(t))}}],function(e,t){for(var n=0;n{n.d(t,{P:()=>s});var r=n("./src/model/physics/constants.ts");function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var s=/*#__PURE__*/function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t)}return e=[{key:"scaleToRadius",value:function(e){t.tableX=43*e,t.tableY=21*e,t.X=t.tableX+e,t.Y=t.tableY+e}}],function(e,t){for(var n=0;n{e(e.s="./src/diagrams.ts")}]); \ No newline at end of file +"use strict";(self.webpackChunkbilliards=self.webpackChunkbilliards||[]).push([[338],{"./src/container/container.ts":(e,t,n)=>{n.d(t,{m:()=>J});var r=n("./src/events/stationaryevent.ts"),i=n("./node_modules/three/build/three.module.js"),s=n("./src/utils/utils.ts"),o=n("./src/view/cameratop.ts"),a=n("./src/model/physics/constants.ts");function l(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var c=/*#__PURE__*/function(){var e;function t(e){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),l(this,"camera",void 0),l(this,"mode",this.topView),l(this,"mainMode",this.aimView),l(this,"height",8*a.R),l(this,"elapsed",void 0),this.camera=new i.ubm(45,e,a.R,1e3*a.R)}return e=[{key:"update",value:function(e,t){this.elapsed=e,this.mode(t)}},{key:"topView",value:function(e){this.camera.fov=o.v.fov,this.camera.position.lerp(o.v.viewPoint(this.camera.aspect,this.camera.fov),.9),this.camera.up=s.up,this.camera.lookAt(s.v_)}},{key:"aimView",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.08,n=this.height,r=this.camera.aspect<.8;if(this.camera.fov=r?60:40,n<10*a.R){var i=100*(10*a.R-n);this.camera.fov-=i*(r?3:1)}this.camera.position.lerp(e.pos.clone().addScaledVector((0,s.Dz)(e.angle),-(18*a.R)),t),this.camera.position.z=n,this.camera.up=s.up,this.camera.lookAt(e.pos.clone().addScaledVector(s.up,n/2))}},{key:"adjustHeight",value:function(e){e=this.height<10*a.R?e/8:e,this.height=i.cj9.clamp(this.height+e,6*a.R,120*a.R),this.height>110*a.R&&this.suggestMode(this.topView),this.height<105*a.R&&this.suggestMode(this.aimView)}},{key:"suggestMode",value:function(e){this.mainMode===this.aimView&&(this.mode=e)}},{key:"forceMode",value:function(e){this.mode=e,this.mainMode=e}},{key:"forceMove",value:function(e){this.mode===this.aimView&&this.aimView(e,1)}},{key:"toggleMode",value:function(){this.mode===this.topView?this.mode=this.aimView:this.mode=this.topView,this.mainMode=this.mode}}],function(e,t){for(var n=0;n0&&(null===(t=this.cuePowerElement)||void 0===t?void 0:t.value)&&(this.cuePowerElement.value=e)}}],function(e,t){for(var n=0;nthis.sentTime+this.period||e.type!==N.B.AIM){this.flush(),this.apply(e),this.sentTime=performance.now();return}this.pending=e}}],function(e,t){for(var n=0;n0&&"RERACK"===this.shots[e].type&&e--,e}},{key:"lastShot",value:function(){var e=this.last();return this.state(this.states[e],[this.shots[e]])}},{key:"currentBreak",value:function(){if(void 0!==this.breakStart)return this.state(this.states[this.breakStart],this.shots.slice(this.breakStart),this.breakStartTime,this.container.rules.previousBreak)}},{key:"state",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];return{init:e,shots:t,start:n,now:Date.now(),score:r,wholeGame:i}}},{key:"updateBreak",value:function(e){var t=this.container.rules.isPartOfBreak(e),n=this.container.rules.isEndOfGame(e),r=D.P.potCount(e);if(t||this.breakLink(n),this.lastShotLink(t||n,r,D.P.pots(e)),n&&this.breakLink(n),!t){this.breakStart=void 0;return}void 0===this.breakStart&&(this.breakStart=this.last(),this.breakStartTime=Date.now())}},{key:"lastShotLink",value:function(e,t,n){var r="#000000";n.length>0&&n.forEach(function(e){r="#"+e.ballmesh.color.getHexString()});var i="⚈".repeat(t>1?t-1:0)+(e?"⚈":"⚆"),s=JSON.stringify(this.lastShot());this.generateLink(i,s,r)}},{key:"breakLink",value:function(e){var t=this.currentBreak();if(t&&(e||t.shots.pop(),1!==t.shots.length)){var n=0===this.container.rules.currentBreak?this.container.rules.previousBreak:this.container.rules.currentBreak;t.score=n;var r=JSON.stringify(t),i=z.A.crush(r);this.generateLink("break(".concat(n,")"),i,"black"),n>=4&&this.generateHiScoreLink(i)}}},{key:"wholeGameLink",value:function(){var e=this.wholeGame(),t="frame(".concat(this.shotCount(e.shots)," shots)"),n=JSON.stringify(e),r=z.A.crush(n);this.generateLink(t,r,"black")}},{key:"shotCount",value:function(e){return e.filter(function(e){return"RERACK"!==e.type}).length}},{key:"generateLink",value:function(e,t,n){var r="".concat(this.replayUrl).concat(this.fullyEncodeURI(t)),i='').concat(e,"");this.container.eventQueue.push(new L.b(null,"".concat(i)))}},{key:"generateHiScoreLink",value:function(e){var t="".concat(this.hiScoreUrl,"?ruletype=").concat(this.container.rules.rulename,"&state=").concat(this.fullyEncodeURI(e)),n='').concat("hi score 🏆","");this.container.eventQueue.push(new L.b(null,"".concat(n)))}},{key:"fullyEncodeURI",value:function(e){return encodeURIComponent(e).replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/\!/g,"%21").replace(/\*/g,"%2A")}}],function(e,t){for(var n=0;n').concat(e,"")));r.push(new L.b(null,o))})},this.redo.onclick=function(e){var r=new X.W(t.init,t.shots);r.retry=!0,n.interuptEventQueue(r)},this.replay.onclick=function(e){n.interuptEventQueue(t)}}}},{key:"interuptEventQueue",value:function(e){this.container.table.halt();var t=this.container.eventQueue;t.length=0,t.push(new r.T),t.push(e)}},{key:"getElement",value:function(e){return document.getElementById(e)}}],function(e,t){for(var n=0;n0?this.element.innerHTML="Break
"+e:this.element.innerHTML="")}},{key:"getElement",value:function(e){return document.getElementById(e)}}],function(e,t){for(var n=0;n0;){this.lastEventTime=this.last;var t=this.inputQueue.shift();t&&this.updateController(this.controller.handleInput(t))}if(this.table.allStationary()){var n=this.eventQueue.shift();n&&(this.lastEventTime=performance.now(),this.updateController(n.applyToController(this.controller)))}}},{key:"animate",value:function(e){var t=this;this.advance((e-this.last)/1e3),this.last=e,this.processEvents(),(e{n.d(t,{m:()=>u});var r=n("./src/controller/controller.ts"),i=n("./src/controller/controllerbase.ts"),s=n("./src/controller/playshot.ts"),o=n("./src/controller/replay.ts");function a(e){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function l(e,t){return(l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(c=function(){return!!e})()}var u=/*#__PURE__*/function(e){var t;function n(e){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,n),r=n,i=[e],r=a(r);var t,r,i,s,o=(s=(t=c()?Reflect.construct(r,i||[],a(this).constructor):r.apply(this,i))&&("object"==(t&&"undefined"!=typeof Symbol&&t.constructor===Symbol?"symbol":typeof t)||"function"==typeof t)?t:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this)).container.table;return o.cue.aimMode(),o.cue.showHelper(!0),o.cueball=s.container.rules.cueball,o.cue.moveTo(o.cueball.pos),s.container.view.camera.suggestMode(s.container.view.camera.aimView),o.cue.aimInputs.showOverlap(),s}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&l(e,t)}(n,e),t=[{key:"handleInput",value:function(e){switch(e.key){case"Space":this.container.table.cue.adjustPower(e.t*this.scale*.7);break;case"SpaceUp":return this.playShot();default:if(!this.commonKeyHandler(e))return this}return this.container.sendEvent(this.container.table.cue.aim),this}},{key:"handleBreak",value:function(e){return new o.e(this.container,e.init,e.shots,e.retry)}},{key:"playShot",value:function(){var e=new r.Qe(this.container.table.serialise());return this.container.sendEvent(e),this.container.recorder.record(e),new s.H(this.container)}}],function(e,t){for(var n=0;n{n.d(t,{Qe:()=>r.Q,pd:()=>i.p,xI:()=>s}),n("./src/events/beginevent.ts"),n("./src/events/aimevent.ts");var r=n("./src/events/hitevent.ts"),i=n("./src/events/input.ts");n("./src/events/abortevent.ts"),n("./src/events/stationaryevent.ts");var s=/*#__PURE__*/function(){var e;function t(e){var n,r;!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),r=void 0,(n="container")in this?Object.defineProperty(this,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):this[n]=r,this.container=e}return e=[{key:"handleInput",value:function(e){return this}},{key:"handleBegin",value:function(e){return this}},{key:"handleBreak",value:function(e){return this}},{key:"handleStartAim",value:function(e){return this}},{key:"handleAim",value:function(e){return this}},{key:"handleHit",value:function(e){return this}},{key:"handleAbort",value:function(e){return this}},{key:"handleWatch",value:function(e){return this}},{key:"handlePlaceBall",value:function(e){return this}},{key:"handleStationary",value:function(e){return this}},{key:"handleChat",value:function(e){return this}},{key:"handleRejoin",value:function(e){return this}},{key:"onFirst",value:function(){}}],function(e,t){for(var n=0;n{n.d(t,{y:()=>f});var r=n("./src/controller/controller.ts"),i=n("./src/controller/end.ts"),s=n("./src/utils/gltf.ts"),o=n("./src/model/outcome.ts"),a=n("./node_modules/three/build/three.module.js");function l(e){return(l=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function u(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function h(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(h=function(){return!!e})()}var f=/*#__PURE__*/function(e){var t;function n(){var e,t,r,i,s;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,n),t=n,r=arguments,t=l(t),(i="scale")in(e=(s=h()?Reflect.construct(t,r||[],l(this).constructor):t.apply(this,r))&&("object"===u(s)||"function"==typeof s)?s:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this))?Object.defineProperty(e,i,{value:.001,enumerable:!0,configurable:!0,writable:!0}):e[i]=.001,e}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c(e,t)}(n,e),t=[{key:"handleAbort",value:function(e){return new i.o(this.container)}},{key:"handleChat",value:function(e){var t=e.sender?"".concat(e.sender,":"):"",n="".concat(t," ").concat(e.message);return this.container.chat.showMessage(n),this}},{key:"hit",value:function(){this.container.table.outcome=[o.P.hit(this.container.table.cueball,this.container.table.cue.aim.power)],this.container.table.hit(),this.container.view.camera.suggestMode(this.container.view.camera.aimView),this.container.table.cue.showHelper(!1)}},{key:"commonKeyHandler",value:function(e){var t=this.container.table.cue,n=e.t*this.scale;switch(e.key){case"ArrowLeft":return t.rotateAim(-n,this.container.table),!0;case"ArrowRight":return t.rotateAim(n,this.container.table),!0;case"ArrowDown":return t.adjustSpin(new a.Pq0(0,-n),this.container.table),!0;case"ArrowUp":return t.adjustSpin(new a.Pq0(0,n),this.container.table),!0;case"ShiftArrowLeft":return t.adjustSpin(new a.Pq0(n,0),this.container.table),!0;case"ShiftArrowRight":return t.adjustSpin(new a.Pq0(-n,0),this.container.table),!0;case"KeyPUp":return(0,s.KP)(this.container.view.scene),!0;case"KeyHUp":return t.toggleHelper(),!0;case"movementXUp":return t.rotateAim(2*n,this.container.table),!0;case"movementYUp":case"NumpadSubtract":return this.container.view.camera.adjustHeight(8*n),!0;case"NumpadAdd":return this.container.view.camera.adjustHeight(-(8*n)),!0;case"KeyOUp":return this.container.view.camera.toggleMode(),!0;case"KeyDUp":return this.togglePanel(),!0;case"KeyFUp":return this.toggleFullscreen(),!0;default:return!1}}},{key:"togglePanel",value:function(){this.container.sliders.toggleVisibility(),this.container.table.showSpin(!0),this.container.table.showTraces(!0),("undefined"==typeof process?"undefined":u(process))!=="object"&&console.log(this.container.table.serialise())}},{key:"toggleFullscreen",value:function(){document.fullscreenElement?document.exitFullscreen&&document.exitFullscreen():document.documentElement.requestFullscreen()}}],function(e,t){for(var n=0;n{function r(e){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function i(e,t){return(i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function s(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(s=function(){return!!e})()}n.d(t,{o:()=>o});var o=/*#__PURE__*/function(e){var t;function n(){var e,t,i;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,n),e=n,t=arguments,e=r(e),(i=s()?Reflect.construct(e,t||[],r(this).constructor):e.apply(this,t))&&("object"==(i&&"undefined"!=typeof Symbol&&i.constructor===Symbol?"symbol":typeof i)||"function"==typeof i)?i:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this)}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&i(e,t)}(n,e),t=[{key:"handleChat",value:function(e){var t=e.sender?"".concat(e.sender,":"):"",n="".concat(t," ").concat(e.message);return this.container.chat.showMessage(n),this}}],function(e,t){for(var n=0;n{n.d(t,{x:()=>p});var r=n("./src/controller/controllerbase.ts"),i=n("./src/controller/controller.ts"),s=n("./src/controller/aim.ts"),o=n("./src/events/breakevent.ts"),a=n("./src/model/physics/constants.ts"),l=n("./node_modules/three/build/three.module.js"),c=n("./src/view/cuemesh.ts");function u(e){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function h(e,t){return(h=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function f(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(f=function(){return!!e})()}var p=/*#__PURE__*/function(e){var t;function n(e){var t,r,i,s,o,l,c;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,n),r=n,i=[e],r=u(r),s=t=(c=f()?Reflect.construct(r,i||[],u(this).constructor):r.apply(this,i))&&("object"==(c&&"undefined"!=typeof Symbol&&c.constructor===Symbol?"symbol":typeof c)||"function"==typeof c)?c:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this),o="placescale",l=.02*a.R,o in s?Object.defineProperty(s,o,{value:l,enumerable:!0,configurable:!0,writable:!0}):s[o]=l,t.container.table.cue.moveTo(t.container.table.cueball.pos),t.container.table.cue.aim.power=0,t.container.view.camera.forceMode(t.container.view.camera.aimView),t}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&h(e,t)}(n,e),t=[{key:"onFirst",value:function(){var e=this.container.table.cueball;this.container.rules.allowsPlaceBall()&&e.pos.copy(this.container.rules.placeBall()),e.setStationary(),e.updateMesh(0),this.container.table.cue.placeBallMode(),this.container.table.cue.showHelper(!1),this.container.table.cue.moveTo(this.container.table.cueball.pos),this.container.table.cue.aimInputs.setButtonText("Place\nBall"),this.container.rules.allowsPlaceBall()||this.container.inputQueue.push(new i.pd(1,"SpaceUp"))}},{key:"handleInput",value:function(e){var t=this.container.table.cueball.pos;switch(e.key){case"ArrowLeft":case"KeyI":this.moveTo(0,e.t*this.placescale);break;case"ArrowRight":case"KeyK":this.moveTo(0,-e.t*this.placescale);break;case"movementXUp":this.moveTo(0,-e.t*this.placescale*2);break;case"movementYUp":this.moveTo(-e.t*this.placescale*2,0);break;case"KeyJ":this.moveTo(-e.t*this.placescale,0);break;case"KeyL":this.moveTo(e.t*this.placescale,0);break;case"SpaceUp":return this.placed();default:this.commonKeyHandler(e)}return this.container.table.cue.moveTo(t),this.container.view.camera.forceMove(this.container.table.cue.aim),this.container.sendEvent(this.container.table.cue.aim),this}},{key:"moveTo",value:function(e,t){var n=new l.Pq0(e,t),r=this.container.table.cueball.pos.add(n);r.copy(this.container.rules.placeBall(r)),c.l.indicateValid(!this.container.table.overlapsAny(r))}},{key:"placed",value:function(){return this.container.table.overlapsAny(this.container.table.cueball.pos)?this:(this.container.table.cue.aimInputs.setButtonText("Hit"),this.container.sound.playNotify(),this.container.sendEvent(new o.W(this.container.table.shortSerialise())),new s.m(this.container))}}],function(e,t){for(var n=0;n{function r(e){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function i(e,t){return(i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function s(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(s=function(){return!!e})()}n.d(t,{H:()=>o});var o=/*#__PURE__*/function(e){var t;function n(e){var t,i,o,a;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,n),i=n,o=[e],i=r(i),(t=(a=s()?Reflect.construct(i,o||[],r(this).constructor):i.apply(this,o))&&("object"==(a&&"undefined"!=typeof Symbol&&a.constructor===Symbol?"symbol":typeof a)||"function"==typeof a)?a:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this)).hit(),t}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&i(e,t)}(n,e),t=[{key:"handleStationary",value:function(e){var t=this.container.table,n=t.outcome,r=this.container.rules.update(n);return this.container.recorder.updateBreak(n),t.cue.aimAtNext(t.cueball,this.container.rules.nextCandidateBall()),r}},{key:"handleInput",value:function(e){return this.commonKeyHandler(e),this}}],function(e,t){for(var n=0;n{n.d(t,{e:()=>m});var r=n("./src/events/hitevent.ts"),i=n("./src/controller/controllerbase.ts"),s=n("./src/events/aimevent.ts"),o=n("./src/events/breakevent.ts"),a=n("./src/controller/aim.ts"),l=n("./src/events/eventtype.ts"),c=n("./src/events/rerackevent.ts");function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n3&&void 0!==arguments[3]&&arguments[3],u=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1500;if(!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,n),s=n,a=[e],s=f(s),h(l=(i=v()?Reflect.construct(s,a||[],f(this).constructor):s.apply(this,a))&&("object"==(i&&"undefined"!=typeof Symbol&&i.constructor===Symbol?"symbol":typeof i)||"function"==typeof i)?i:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this),"delay",void 0),h(l,"shots",void 0),h(l,"firstShot",void 0),h(l,"timer",void 0),h(l,"init",void 0),l.init=t,l.shots=d(r),l.firstShot=l.shots[0],l.delay=u,l.container.table.showTraces(!0),l.container.table.updateFromShortSerialised(l.init),c){var p=new o.W(t,r);p.retry=!0,l.container.eventQueue.push(p)}else l.container.view.camera.forceMode(l.container.view.camera.topView),l.playNextShot(1.5*l.delay);return l}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&p(e,t)}(n,e),t=[{key:"playNextShot",value:function(e){var t=this,n=this.shots.shift();if((null==n?void 0:n.type)===l.B.RERACK){c.x.fromJson(n.ballinfo).applyToController(this),this.shots.length>0&&this.playNextShot(e);return}var i=s.w.fromJson(n);this.container.table.cueball=this.container.table.balls[i.i],console.log(this.container.table.cueball.pos.distanceTo(i.pos)),this.container.table.cueball.pos.copy(i.pos),this.container.table.cue.aim=i,this.container.table.cue.updateAimInput(),this.container.table.cue.t=1,clearTimeout(this.timer),this.timer=setTimeout(function(){t.container.eventQueue.push(new r.Q(t.container.table.cue.aim)),t.timer=void 0},e)}},{key:"handleHit",value:function(e){return this.hit(),this}},{key:"handleStationary",value:function(e){return this.shots.length>0&&void 0===this.timer&&this.playNextShot(this.delay),this}},{key:"handleInput",value:function(e){return this.commonKeyHandler(e),this}},{key:"handleBreak",value:function(e){return(this.container.table.updateFromShortSerialised(e.init),this.shots=d(e.shots),this.container.table.showSpin(!0),e.retry)?this.retry():(this.playNextShot(this.delay),this)}},{key:"retry",value:function(){clearTimeout(this.timer),this.timer=void 0,this.container.table.updateFromShortSerialised(this.init);var e=s.w.fromJson(this.firstShot);return this.container.table.cueball=this.container.table.balls[e.i],this.container.rules.cueball=this.container.table.cueball,this.container.table.cueball.pos.copy(e.pos),this.container.table.cue.aim=e,this.container.view.camera.forceMode(this.container.view.camera.aimView),new a.m(this.container)}}],function(e,t){for(var n=0;n{n.d(t,{V:()=>M});var r=n("./src/events/watchevent.ts"),i=n("./src/utils/rack.ts"),s=n("./node_modules/three/build/three.module.js"),o=n("./src/controller/aim.ts"),a=n("./src/controller/placeball.ts"),l=n("./src/controller/watchaim.ts"),c=n("./src/events/chatevent.ts"),u=n("./src/events/placeballevent.ts"),h=n("./src/model/outcome.ts"),f=n("./src/model/table.ts"),p=n("./src/utils/utils.ts"),d=n("./src/controller/end.ts"),v=n("./src/model/physics/constants.ts"),m=n("./src/utils/respot.ts"),y=n("./src/view/tablegeometry.ts"),b=n("./src/events/startaimevent.ts");function g(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var w=/*#__PURE__*/function(){var e;function t(e){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),g(this,"container",void 0),g(this,"cueball",void 0),g(this,"currentBreak",0),g(this,"previousBreak",0),g(this,"score",0),g(this,"rulename","nineball"),this.container=e}return e=[{key:"startTurn",value:function(){this.previousBreak=this.currentBreak,this.currentBreak=0}},{key:"nextCandidateBall",value:function(){return m.k.closest(this.container.table.cueball,this.container.table.balls)}},{key:"placeBall",value:function(e){if(e){var t=new s.Pq0(-y.P.X/2,y.P.tableY),n=new s.Pq0(-y.P.tableX,-y.P.tableY);return e.clamp(n,t)}return new s.Pq0(-(11*v.R)/.5,0,0)}},{key:"asset",value:function(){return"models/p8.min.gltf"}},{key:"tableGeometry",value:function(){y.P.hasPockets=!0}},{key:"table",value:function(){var e=new f.X(this.rack());return this.cueball=e.cueball,e}},{key:"rack",value:function(){return i.m.diamond()}},{key:"update",value:function(e){var t=this.container.table;if(h.P.isCueBallPotted(t.cueball,e))return(this.startTurn(),this.container.isSinglePlayer)?new a.x(this.container):(this.container.sendEvent(new u.z(p.v_,!0)),new l.r(this.container));if(h.P.isBallPottedNoFoul(t.cueball,e)){var n=h.P.potCount(e);return(this.currentBreak+=n,this.score+=n,this.container.sound.playSuccess(t.inPockets()),this.isEndOfGame(e))?(this.container.eventQueue.push(new c.b(null,"game over")),this.container.recorder.wholeGameLink(),new d.o(this.container)):(this.container.sendEvent(new r.Q(t.serialise())),new o.m(this.container))}return(this.container.sendEvent(new b.M),this.container.isSinglePlayer)?(this.container.sendEvent(new r.Q(t.serialise())),this.startTurn(),new o.m(this.container)):new l.r(this.container)}},{key:"isPartOfBreak",value:function(e){return h.P.isBallPottedNoFoul(this.container.table.cueball,e)}},{key:"isEndOfGame",value:function(e){var t=this.container.table.balls.filter(function(e){return e.onTable()});return 1===t.length&&t[0]===this.cueball}},{key:"otherPlayersCueBall",value:function(){return this.cueball}},{key:"secondToPlay",value:function(){}},{key:"allowsPlaceBall",value:function(){return!0}}],function(e,t){for(var n=0;n{n.d(t,{c:()=>k});var r=n("./node_modules/three/build/three.module.js"),i=n("./src/events/watchevent.ts"),s=n("./src/model/outcome.ts"),o=n("./src/utils/rack.ts"),a=n("./src/utils/respot.ts"),l=n("./src/controller/aim.ts"),c=n("./src/controller/watchaim.ts"),u=n("./src/events/chatevent.ts"),h=n("./src/controller/end.ts"),f=n("./src/model/table.ts"),p=n("./src/view/tablegeometry.ts"),d=n("./src/controller/placeball.ts"),v=n("./src/events/placeballevent.ts"),m=n("./src/utils/utils.ts"),y=/*#__PURE__*/function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t)}return e=[{key:"shotInfo",value:function(e,n,r){var i=s.P.firstCollision(n);return{pots:s.P.potCount(n),firstCollision:i,legalFirstCollision:t.isLegalFirstCollision(e,r,i),whitePotted:s.P.isCueBallPotted(e.cueball,n)}}},{key:"isLegalFirstCollision",value:function(e,n,r){if(!r)return!1;var i=r.ballB.id;return n?i>=7:!(t.coloursOnTable(e).filter(function(e){return e.id0)}},{key:"respotAllPottedColours",value:function(e,t){return s.P.pots(t).filter(function(e){return e.id<7}).filter(function(e){return 0!==e.id}).map(function(t){return a.k.respot(t,e)})}},{key:"redsOnTable",value:function(e){return e.balls.slice(7).filter(function(e){return e.onTable()})}},{key:"coloursOnTable",value:function(e){return e.balls.slice(1,7).filter(function(e){return e.onTable()})}}],function(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,r=Array(t);n0,this.switchPlayer()}return this.targetIsRed?this.targetRedRule(e,t):this.targetColourRule(e,t)}},{key:"targetRedRule",value:function(e,t){return(console.log("applying target red rule"),t.legalFirstCollision&&s.P.onlyRedsPotted(e))?(this.currentBreak+=t.pots,this.targetIsRed=!1,this.previousPotRed=!0,this.container.hud.updateBreak(this.currentBreak),this.continueBreak()):(this.foulPoints=this.foulCalculation(e,t),this.respot(e),t.whitePotted)?this.whiteInHand():this.switchPlayer()}},{key:"targetColourRule",value:function(e,t){if(console.log("applying target colour rule"),t.whitePotted)return this.respot(e),this.whiteInHand();if(t.pots>1)return this.foulPoints=this.foulCalculation(e,t),this.respot(e),this.switchPlayer();if(s.P.pots(e)[0].id>6)return this.foulPoints=this.foulCalculation(e,t),this.switchPlayer();this.targetIsRed=y.redsOnTable(this.container.table).length>0;var n=s.P.pots(e)[0].id;return n!==t.firstCollision.ballB.id?this.foul(e,t):this.previousPotRed?(this.respot(e),this.currentBreak+=n+1,this.previousPotRed=!1,this.continueBreak()):y.coloursOnTable(this.container.table).filter(function(e){return e.id0?this.foul(e,t):(this.currentBreak+=n+1,this.previousPotRed=!1,this.continueBreak())}},{key:"foul",value:function(e,t){return this.foulPoints=this.foulCalculation(e,t),this.respot(e),this.switchPlayer()}},{key:"foulCalculation",value:function(e,t){var n,r,i,o,a=s.P.pots(e).map(function(e){return e.id}).filter(function(e){return e<7}),l=null!==(o=null===(i=t.firstCollision)||void 0===i?void 0:null===(r=i.ballB)||void 0===r?void 0:r.id)&&void 0!==o?o:0;return l>6&&(l=0),(n=Math).max.apply(n,[3,l].concat(function(e){if(Array.isArray(e))return g(e)}(a)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(a)||function(e,t){if(e){if("string"==typeof e)return g(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return g(e,void 0)}}(a)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()))+1}},{key:"tableGeometry",value:function(){p.P.hasPockets=!0}},{key:"table",value:function(){var e=new f.X(this.rack());return this.cueball=e.cueball,e}},{key:"otherPlayersCueBall",value:function(){return this.cueball}},{key:"secondToPlay",value:function(){}},{key:"isPartOfBreak",value:function(e){return this.currentBreak>0}},{key:"isEndOfGame",value:function(e){return s.P.isClearTable(this.container.table)&&this.currentBreak>0}},{key:"allowsPlaceBall",value:function(){return!0}},{key:"asset",value:function(){return t.tablemodel}},{key:"startTurn",value:function(){this.previousPotRed=!1,this.targetIsRed=y.redsOnTable(this.container.table).length>0,this.previousBreak=this.currentBreak,this.score+=this.currentBreak,this.currentBreak=0,this.container.hud.updateBreak(this.currentBreak)}},{key:"rack",value:function(){return o.m.snooker()}},{key:"nextCandidateBall",value:function(){var e=this.container.table,t=y.redsOnTable(e),n=y.coloursOnTable(e);return this.previousPotRed?a.k.closest(e.cueball,n):t.length>0?a.k.closest(e.cueball,t):n.length>0?n[0]:void 0}},{key:"placeBall",value:function(e){if(e){var t=new r.Pq0(o.m.baulk,0,0),n=o.m.sixth,i=e.distanceTo(t);if(e.x>=o.m.baulk&&(e.x=o.m.baulk),!(i>n))return e;var s=e.clone().sub(t).normalize();return t.add(s.multiplyScalar(n))}return new r.Pq0(o.m.baulk,-o.m.sixth/2.6,0)}},{key:"switchPlayer",value:function(){this.foulPoints>0&&console.log("foul, ".concat(this.foulPoints," to opponent")),console.log("end of break, switch player");var e=this.container.table;return(console.log(e.cue.aim),this.container.sendEvent(new b.M(this.foulPoints)),this.container.isSinglePlayer)?(this.container.sendEvent(new i.Q(e.serialise())),this.startTurn(),new l.m(this.container)):new c.r(this.container)}},{key:"continueBreak",value:function(){this.container.hud.updateBreak(this.currentBreak);var e=this.container.table;return(this.container.sound.playSuccess(e.inPockets()),s.P.isClearTable(e))?(this.container.eventQueue.push(new u.b(null,"game over")),this.container.recorder.wholeGameLink(),new h.o(this.container)):(this.container.sendEvent(new i.Q(e.serialise())),new l.m(this.container))}},{key:"whiteInHand",value:function(){return(this.foulPoints>0&&console.log("foul, ".concat(this.foulPoints," to opponent")),this.startTurn(),this.container.isSinglePlayer)?new d.x(this.container):(this.container.sendEvent(new v.z(m.v_,!0)),new c.r(this.container))}},{key:"update",value:function(e){return this.snookerrule(e)}},{key:"respot",value:function(e){var t=y.respotAllPottedColours(this.container.table,e);if(t.length>0){var n={balls:t.map(function(e){return e.serialise()}),rerack:!0},r=new i.Q(n);this.container.sendEvent(r),this.container.recorder.record(r)}}}],function(e,t){for(var n=0;n{n.d(t,{r:()=>a});var r=n("./src/controller/watchshot.ts");function i(e){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function o(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(o=function(){return!!e})()}var a=/*#__PURE__*/function(e){var t;function n(e){var t,r,s,a;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,n),r=n,s=[e],r=i(r),(t=(a=o()?Reflect.construct(r,s||[],i(this).constructor):r.apply(this,s))&&("object"==(a&&"undefined"!=typeof Symbol&&a.constructor===Symbol?"symbol":typeof a)||"function"==typeof a)?a:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this)).container.table.cueball=t.container.rules.otherPlayersCueBall(),t.container.table.cue.moveTo(t.container.table.cueball.pos),t.container.view.camera.suggestMode(t.container.view.camera.topView),t}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}(n,e),t=[{key:"handleAim",value:function(e){return this.container.table.cue.aim=e,this.container.table.cueball.pos.copy(e.pos),this}},{key:"handleHit",value:function(e){return this.container.table.updateFromSerialised(e.tablejson),new r.O(this.container)}}],function(e,t){for(var n=0;n{n.d(t,{O:()=>u});var r=n("./src/controller/aim.ts"),i=n("./src/controller/watchaim.ts"),s=n("./src/controller/controllerbase.ts"),o=n("./src/controller/placeball.ts");function a(e){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function l(e,t){return(l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(c=function(){return!!e})()}var u=/*#__PURE__*/function(e){var t;function n(e){var t,r,i,s;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,n),r=n,i=[e],r=a(r),(t=(s=c()?Reflect.construct(r,i||[],a(this).constructor):r.apply(this,i))&&("object"==(s&&"undefined"!=typeof Symbol&&s.constructor===Symbol?"symbol":typeof s)||"function"==typeof s)?s:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this)).container.table.outcome=[],t.container.table.hit(),t}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&l(e,t)}(n,e),t=[{key:"handleStartAim",value:function(e){return new r.m(this.container)}},{key:"handlePlaceBall",value:function(e){return new o.x(this.container)}},{key:"handleWatch",value:function(e){return"rerack"in e.json?(console.log("Respot"),this.container.table.updateFromSerialised(e.json),this):new i.r(this.container)}}],function(e,t){for(var n=0;n{n.d(t,{M:()=>r,R:()=>i,_:()=>a,ee:()=>s,o:()=>o});var r=.1406,i=.02625,s=.98,o=.212,a=.14},"./src/diagrams.ts":(e,t,n)=>{var r,i,s,o,a,l,c,u,h,f=n("./src/model/physics/physics.ts"),p=n("./node_modules/three/build/three.module.js");function d(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var v=/*#__PURE__*/function(){var e;function t(e,n){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),d(this,"canvas",void 0),d(this,"context",void 0),d(this,"endx",100),d(this,"endy",100),d(this,"scale",2e3),d(this,"r",20),e.firstElementChild.innerHTML=n,this.canvas=e.lastElementChild,this.context=this.canvas.getContext("2d")}return e=[{key:"drawBall",value:function(){this.context.beginPath(),this.context.strokeStyle="lightgray",this.context.fillStyle="beige",this.context.arc(this.endx,this.endy,this.r,0,2*Math.PI,!1),this.context.fill(),this.context.stroke()}},{key:"drawCushion",value:function(){var e=this.context.createLinearGradient(10,90,200,90);e.addColorStop(0,"lightgray"),e.addColorStop(.75,"white"),this.context.fillStyle=e,this.context.fillRect(this.endx+this.r,10,200,250)}},{key:"plot",value:function(e,t,n,r,i){this.context.clearRect(0,0,this.canvas.width,this.canvas.height),this.drawCushion(),this.drawBall();for(var s=e;s<=t;s+=n){var o=r(s),a=i(s),l=(0,f.yO)(o,a)?[]:[2,2];this.context.setLineDash(l);var c=(s+360)*101%360;this.context.strokeStyle="hsl(".concat(c,",50%,50%)"),this.drawArrow(this.endx-o.x*this.scale,this.endy-o.y*this.scale,this.endx,this.endy);var u=(0,f.QK)(0,o,a,f.QV);o.add(u.v),this.drawArrow(this.endx,this.endy,this.endx+o.x*this.scale,this.endy+o.y*this.scale)}}},{key:"drawArrow",value:function(e,t,n,r){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:.9,s={dx:n-e,dy:r-t},o={x:s.dx*i+e,y:s.dy*i+t},a={dx:n-o.x,dy:r-o.y};this.context.beginPath(),this.context.moveTo(e,t),this.context.lineTo(o.x,o.y),this.context.moveTo(o.x+.5*a.dy,o.y-.5*a.dx),this.context.lineTo(o.x-.5*a.dy,o.y+.5*a.dx),this.context.lineTo(n,r),this.context.closePath(),this.context.stroke()}}],function(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,r=Array(t);n{n.d(t,{h:()=>l});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function a(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(a=function(){return!!e})()}var l=/*#__PURE__*/function(e){var t;function n(){var e,t,r,o;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,n),t=s(t=n),(e=(o=a()?Reflect.construct(t,[],s(this).constructor):t.apply(this,r))&&("object"==(o&&"undefined"!=typeof Symbol&&o.constructor===Symbol?"symbol":typeof o)||"function"==typeof o)?o:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this)).type=i.B.ABORT,e}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&o(e,t)}(n,e),t=[{key:"applyToController",value:function(e){return e.handleAbort(this)}}],function(e,t){for(var n=0;n{n.d(t,{w:()=>f});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts"),s=n("./src/utils/utils.ts"),o=n("./node_modules/three/build/three.module.js");function a(e,t){for(var n=0;n{n.d(t,{u:()=>l});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function a(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(a=function(){return!!e})()}var l=/*#__PURE__*/function(e){var t;function n(){var e,t,r,o;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,n),t=s(t=n),(e=(o=a()?Reflect.construct(t,[],s(this).constructor):t.apply(this,r))&&("object"==(o&&"undefined"!=typeof Symbol&&o.constructor===Symbol?"symbol":typeof o)||"function"==typeof o)?o:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this)).type=i.B.BEGIN,e}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&o(e,t)}(n,e),t=[{key:"applyToController",value:function(e){return e.handleBegin(this)}}],function(e,t){for(var n=0;n{n.d(t,{W:()=>u});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function s(e,t){for(var n=0;n{n.d(t,{b:()=>u});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function s(e,t){for(var n=0;n{n.d(t,{B:()=>r});var r=/*#__PURE__*/function(e){return e.BEGIN="BEGIN",e.BREAK="BREAK",e.WATCHAIM="WATCHAIM",e.AIM="AIM",e.HIT="HIT",e.STATIONARY="STATIONARY",e.CHAT="CHAT",e.ABORT="ABORT",e.PLACEBALL="PLACEBALL",e.REJOIN="REJOIN",e.RERACK="RERACK",e.STARTAIM="STARTAIM",e}({})},"./src/events/gameevent.ts":(e,t,n)=>{function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}n.d(t,{F:()=>i});var i=function e(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,e),r(this,"type",void 0),r(this,"sequence",void 0)}},"./src/events/hitevent.ts":(e,t,n)=>{n.d(t,{Q:()=>c});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function s(e,t){for(var n=0;n{function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}n.d(t,{p:()=>i});var i=function e(t,n){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,e),r(this,"t",void 0),r(this,"key",void 0),this.t=t,this.key=n}},"./src/events/keyboard.ts":(e,t,n)=>{n.d(t,{s:()=>a});var r=n("./src/events/input.ts"),i=n("./node_modules/interactjs/dist/interact.min.js"),s=/*#__PURE__*/n.n(i);function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var a=/*#__PURE__*/function(){var e;function t(e){var n=this;!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),o(this,"pressed",{}),o(this,"released",{}),o(this,"keydown",function(e){null==n.pressed[e.code]&&(n.pressed[e.code]=performance.now()),e.stopImmediatePropagation(),"F12"!==e.key&&e.preventDefault()}),o(this,"keyup",function(e){n.released[e.code]=performance.now()-n.pressed[e.code],delete n.pressed[e.code],e.stopImmediatePropagation(),"F12"!==e.key&&e.preventDefault()}),o(this,"mousetouch",function(e){var t,r,i=n.released,s=e.client.yMath.abs(i.movementY)&&(i.movementY=0)}),this.addHandlers(e),/Android|iPhone/i.test(navigator.userAgent)||(e.contentEditable="true")}return e=[{key:"getEvents",value:function(){var e=this,t=Object.keys(this.pressed).filter(function(e){return!/Shift/.test(e)}).filter(function(e){return!/Control/.test(e)}),n=Object.keys(this.pressed).some(function(e){return/Shift/.test(e)}),i=Object.keys(this.pressed).some(function(e){return/Control/.test(e)}),s=[];return t.forEach(function(t){var o=performance.now()-e.pressed[t];s.push(new r.p(i?o/3:o,n?"Shift"+t:t)),"Space"!=t&&(e.pressed[t]=performance.now())}),Object.keys(this.released).forEach(function(t){return s.push(new r.p(e.released[t],t+"Up"))}),this.released={},s}},{key:"addHandlers",value:function(e){var t=this;e.addEventListener("keydown",this.keydown),e.addEventListener("keyup",this.keyup),e.focus(),s()(e).draggable({listeners:{move:function(e){t.mousetouch(e)}}}),s()(e).gesturable({onmove:function(e){e.dx/=3,t.mousetouch(e)}})}}],function(e,t){for(var n=0;n{n.d(t,{z:()=>h});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts"),s=n("./src/utils/utils.ts");function o(e,t){for(var n=0;n{n.d(t,{x:()=>c});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function s(e,t){for(var n=0;n{n.d(t,{M:()=>c});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function s(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:0;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,r),t=o(t=r),(s="foul")in(a=(e=l()?Reflect.construct(t,[],o(this).constructor):t.apply(this,n))&&("object"==(e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e)||"function"==typeof e)?e:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this))?Object.defineProperty(a,s,{value:0,enumerable:!0,configurable:!0,writable:!0}):a[s]=0,a.type=i.B.STARTAIM,a.foul=c,a}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&a(e,t)}(r,e),t=[{key:"applyToController",value:function(e){return e.handleStartAim(this)}}],n=[{key:"fromJson",value:function(e){return new r(e.foul)}}],t&&s(r.prototype,t),n&&s(r,n),r}(r.F)},"./src/events/stationaryevent.ts":(e,t,n)=>{n.d(t,{T:()=>l});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function a(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(a=function(){return!!e})()}var l=/*#__PURE__*/function(e){var t;function n(){var e,t,r,o;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,n),t=s(t=n),(e=(o=a()?Reflect.construct(t,[],s(this).constructor):t.apply(this,r))&&("object"==(o&&"undefined"!=typeof Symbol&&o.constructor===Symbol?"symbol":typeof o)||"function"==typeof o)?o:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this)).type=i.B.STATIONARY,e}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&o(e,t)}(n,e),t=[{key:"applyToController",value:function(e){return e.handleStationary(this)}}],function(e,t){for(var n=0;n{n.d(t,{Q:()=>c});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function s(e,t){for(var n=0;n{n.d(t,{c:()=>d,U:()=>p});var r=n("./src/utils/utils.ts"),i=n("./src/model/physics/physics.ts"),s=n("./node_modules/three/build/three.module.js"),o=n("./src/model/physics/constants.ts");function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var l=/*#__PURE__*/function(){var e;function t(e,n){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),a(this,"line",void 0),a(this,"geometry",void 0),a(this,"positions",void 0),a(this,"lastPos",new s.Pq0),a(this,"lastVel",new s.Pq0),this.geometry=new s.LoY,this.positions=new Float32Array(3*e),this.geometry.setAttribute("position",new s.THS(this.positions,3)),this.reset();var r=new s.mrM({color:n,opacity:.25,linewidth:3,transparent:!0});this.line=new s.N1A(this.geometry,r),this.line.visible=!1}return e=[{key:"reset",value:function(){this.geometry.setDrawRange(0,0),this.lastVel.setZ(1)}},{key:"forceTrace",value:function(e){this.lastVel.z=1,this.addTraceGiven(e,this.lastVel,1,.1,1)}},{key:"addTrace",value:function(e,t){if(0!==t.length()){var n=this.lastVel.angleTo(t),r=n>Math.PI/32?.01*o.R:o.R,i=this.lastPos.distanceTo(e);this.addTraceGiven(e,t,i,r,n)}}},{key:"addTraceGiven",value:function(e,t,n,r,i){var s=this.geometry.drawRange.count;0!==s&&n1&&i<1e-4&&s--,this.lastPos.copy(e),this.lastVel.copy(t),this.addPoint(e,s))}},{key:"addPoint",value:function(e,t){var n=3*t;n>this.positions.length||(this.positions[n++]=e.x,this.positions[n++]=e.y,this.positions[n]=e.z,this.geometry.setDrawRange(0,t+1),this.line.geometry.attributes.position.needsUpdate=!0)}}],function(e,t){for(var n=0;nMath.abs(this.rvel.z))&&(this.setStationary(),!0)}},{key:"setStationary",value:function(){this.vel.copy(r.v_),this.rvel.copy(r.v_),this.state="Stationary"}},{key:"isRolling",value:function(){return 0!==this.vel.lengthSq()&&0!==this.rvel.lengthSq()&&(0,i.Mq)(this.vel,this.rvel).length(){function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}n.d(t,{P:()=>i});var i=/*#__PURE__*/function(){var e;function t(e,n,i,s){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),r(this,"type",void 0),r(this,"timestamp",void 0),r(this,"ballA",null),r(this,"ballB",null),r(this,"incidentSpeed",void 0),this.type=e,this.ballA=n,this.ballB=i,this.incidentSpeed=s,this.timestamp=Date.now()}return e=[{key:"pot",value:function(e,n){return new t("Pot",e,e,n)}},{key:"cushion",value:function(e,n){return new t("Cushion",e,e,n)}},{key:"collision",value:function(e,n,r){return new t("Collision",e,n,r)}},{key:"hit",value:function(e,n){return new t("Hit",e,e,n)}},{key:"isCueBallPotted",value:function(e,t){return t.some(function(t){return"Pot"==t.type&&t.ballA===e})}},{key:"isBallPottedNoFoul",value:function(e,n){return n.some(function(e){return"Pot"==e.type&&null!==e.ballA})&&!t.isCueBallPotted(e,n)}},{key:"pots",value:function(e){return e.filter(function(e){return"Pot"==e.type}).map(function(e){return e.ballA})}},{key:"potCount",value:function(e){return this.pots(e).length}},{key:"onlyRedsPotted",value:function(e){return this.pots(e).every(function(e){return e.id>6})}},{key:"firstCollision",value:function(e){var t=e.filter(function(e){return"Collision"===e.type});return t.length>0?t[0]:void 0}},{key:"isClearTable",value:function(e){var t=e.balls.filter(function(e){return e.onTable()});return 1===t.length&&t[0]===e.cueball}},{key:"isThreeCushionPoint",value:function(e,n){n=t.cueBallFirst(e,n).filter(function(t){return t.ballA===e});var r=new Set,i=0,s=!0,o=!1,a=void 0;try{for(var l,c=n[Symbol.iterator]();!(s=(l=c.next()).done);s=!0){var u=l.value;if("Cushion"===u.type&&i++,"Collision"===u.type&&(r.add(u.ballB),2===r.size))return i>=3}}catch(e){o=!0,a=e}finally{try{s||null==c.return||c.return()}finally{if(o)throw a}}return!1}},{key:"cueBallFirst",value:function(e,t){return t.forEach(function(t){"Collision"===t.type&&t.ballB===e&&(t.ballB=t.ballA,t.ballA=e)}),t}}],function(e,t){for(var n=0;n{n.d(t,{I:()=>s,Mz:()=>r,Qg:()=>b,R:()=>f,Wv:()=>w,Ys:()=>k,Z3:()=>d,cM:()=>x,e:()=>p,g:()=>o,gT:()=>c,gf:()=>l,jG:()=>y,kL:()=>u,kM:()=>T,m:()=>h,mu:()=>a,o5:()=>v,x3:()=>i,xO:()=>g});var r,i,s,o=9.8,a=.00985,l=.16,c=.8,u=.034,h=.23,f=.03275,p=.86,d=.4,v=Math.sqrt(21)/5;function m(){r=a*h*o*2/3*u,i=7/(5*Math.sqrt(2))*f*a*h*o,s=.4*h*f*f}function y(e){f=e,m()}function b(e){h=e,m()}function g(e){a=e,m()}function w(e){u=e,m()}function k(e){l=e}function x(e){p=e}function T(e){c=e}m()},"./src/model/physics/knuckle.ts":(e,t,n)=>{n.d(t,{O:()=>a});var r=n("./src/model/physics/constants.ts"),i=n("./src/view/pocketgeometry.ts");function s(e,t){for(var n=0;n{n.d(t,{z:()=>s});var r=n("./src/model/physics/constants.ts");function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var s=/*#__PURE__*/function(){var e;function t(e,n,r,s,o){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),i(this,"P",0),i(this,"WzI",0),i(this,"vx",void 0),i(this,"vy",void 0),i(this,"ωx",void 0),i(this,"ωy",void 0),i(this,"ωz",void 0),i(this,"s",void 0),i(this,"φ",void 0),i(this,"sʹ",void 0),i(this,"φʹ",void 0),i(this,"i",0),i(this,"N",100),i(this,"M",void 0),i(this,"R",void 0),i(this,"μs",void 0),i(this,"μw",void 0),i(this,"ee",void 0),this.M=e,this.R=n,this.ee=r,this.μs=s,this.μw=o}return e=[{key:"updateSlipSpeedsAndAngles",value:function(){var e=this.R,t=this.vx+this.ωy*e*r.Z3-this.ωz*e*r.o5,n=-this.vy*r.Z3+this.ωx*e,i=this.vx-this.ωy*e,s=this.vy+this.ωx*e;this.s=Math.sqrt(Math.pow(t,2)+Math.pow(n,2)),this.φ=Math.atan2(n,t),this.φ<0&&(this.φ+=2*Math.PI),this.sʹ=Math.sqrt(Math.pow(i,2)+Math.pow(s,2)),this.φʹ=Math.atan2(s,i),this.φʹ<0&&(this.φʹ+=2*Math.PI)}},{key:"compressionPhase",value:function(){for(var e=Math.max(this.M*this.vy/this.N,.001);this.vy>0;)this.updateSingleStep(e)}},{key:"restitutionPhase",value:function(e){var t=Math.max(e/this.N,.001);for(this.WzI=0;this.WzI10*this.N)throw"Solution not found"}},{key:"updateVelocity",value:function(e){var t=this.μs,n=this.μw,i=this.M;this.vx-=1/i*(n*Math.cos(this.φ)+t*Math.cos(this.φʹ)*(r.Z3+n*Math.sin(this.φ)*r.o5))*e,this.vy-=1/i*(r.o5-n*r.Z3*Math.sin(this.φ)+t*Math.sin(this.φʹ)*(r.Z3+n*Math.sin(this.φ)*r.o5))*e}},{key:"updateAngularVelocity",value:function(e){var t=this.μs,n=this.μw,i=this.M,s=this.R;this.ωx+=-(5/(2*i*s))*(n*Math.sin(this.φ)+t*Math.sin(this.φʹ)*(r.Z3+n*Math.sin(this.φ)*r.o5))*e,this.ωy+=-(5/(2*i*s))*(n*Math.cos(this.φ)*r.Z3-t*Math.cos(this.φʹ)*(r.Z3+n*Math.sin(this.φ)*r.o5))*e,this.ωz+=5/(2*i*s)*(n*Math.cos(this.φ)*r.o5)*e}},{key:"updateWorkDone",value:function(e){var t=e*Math.abs(this.vy);this.WzI+=t,this.P+=e}},{key:"solvePaper",value:function(e,t,n,r){this.solve(e*Math.cos(t),e*Math.sin(t),-r*Math.sin(t),r*Math.cos(t),n)}},{key:"solve",value:function(e,t,n,r,i){this.vx=e,this.vy=t,this.ωx=n,this.ωy=r,this.ωz=i,this.WzI=0,this.P=0,this.i=0,this.compressionPhase();var s=this.WzI-(1-this.ee*this.ee)*this.WzI;this.restitutionPhase(s)}}],function(e,t){for(var n=0;n{n.d(t,{$8:()=>S,Gp:()=>k,JD:()=>f,Mq:()=>c,QK:()=>d,QV:()=>R,Qy:()=>M,Un:()=>w,c0:()=>g,lx:()=>p,p2:()=>h,s0:()=>b,t6:()=>_,yO:()=>x});var r=n("./node_modules/three/build/three.module.js"),i=n("./src/utils/utils.ts"),s=n("./src/model/physics/constants.ts"),o=n("./src/model/physics/mathaven.ts"),a=n("./src/diagram/constants.ts"),l=new r.Pq0;function c(e,t){return l.copy(e).addScaledVector((0,i.KM)(t),s.R)}var u={v:new r.Pq0,w:new r.Pq0};function h(e,t){var n=c(e,t).setZ(0);return u.v.copy((0,i.xb)(n).multiplyScalar(-s.gf*s.g)),u.w.copy((0,i.xb)((0,i.KM)(n)).multiplyScalar(2.5*s.gf*s.g/s.R)),u.w.setZ(-2.5*(s.Mz/(s.m*s.R*s.R))*Math.sign(t.z)),u}function f(e){var t=new r.Pq0(e.x,e.y,0).length(),n=5/7*s.x3/(s.m*s.R)/t,i=5/7*s.x3/(s.m*s.R*s.R)/t;return u.v.set(-n*e.y,n*e.x,0),u.w.set(-i*e.x,-i*e.y,-2.5*(s.Mz/(s.m*s.R*s.R))*Math.sign(e.z)),u}function p(e,t){var n=t.z;t.copy((0,i.KM)(e).multiplyScalar(1/s.R)),t.setZ(n)}function d(e,t,n,r){var s=r(t.clone().applyAxisAngle(i.up,e),n.clone().applyAxisAngle(i.up,e));return s.v.applyAxisAngle(i.up,-e),s.w.applyAxisAngle(i.up,-e),s}Object.freeze(u);var v=Math.asin(.1*s.R/s.R),m=Math.sin(v),y=Math.cos(v);function b(e,t){return new r.Pq0(e.x*m-e.z*y+s.R*t.y,-e.y-s.R*t.z*y+s.R*t.x*m)}function g(e){return e.x*y}function w(e){var t=3.5/s.m;return e.length()/t}function k(e){var t,n=1/s.m,i=.39+.257*(t=new r.Pq0(e/y,0,0)).x-.044*t.x*t.x;return s.gT*((1+i)*e)/n}function x(e,t){var n=k(g(e));return w(b(e,t))<=n}function T(e,t){return{c:g(e),s:b(e,t),A:3.5/s.m,B:1/s.m}}function A(e,t){var n=T(e,t),r=n.c,i=n.s,o=n.A,a=n.B,l=(1+s.e)*(r/a);return E(-i.x/o*m-l*y,i.y/o,i.x/o*y-l*m)}function P(e,t){var n=T(e,t),r=n.c,i=n.B,o=(1+s.e)*(r/i),a=.471-.241*Math.atan2(Math.abs(e.y),e.x),l=Math.atan2(e.y,e.x),c=Math.cos(l);return E(-a*o*c*y-o*y,a*o*Math.sin(l),a*o*c*y-o*m)}function R(e,t){return x(e,t)?A(e,t):P(e,t)}function S(e,t){var n=A(e,t),r=P(e,t),i=Math.sign(e.y)===Math.sign(t.z)?Math.cos(Math.atan2(e.y,e.x)):1;return{v:r.v.lerp(n.v,i),w:r.w.lerp(n.w,i)}}function E(e,t,n){return{v:new r.Pq0(e/s.m,t/s.m),w:new r.Pq0(-s.R/s.I*t*m,s.R/s.I*(e*m-n*y),s.R/s.I*t*y)}}function O(e,t){var n=new o.z(s.m,s.R,a.ee,a.o,a._+.1);n.solve(e.x,e.y,t.x,t.y,t.z);var i=new r.Pq0(n.vx,n.vy,0),l=new r.Pq0(n.ωx,n.ωy,n.ωz);return{v:i.sub(e),w:l.sub(t)}}function M(e,t){return d(Math.PI/2,e,t,O)}function _(e,t){var n=Math.atan2(-e.x,e.y),r=2.5*t.length()*(e.length()*s.R)/(s.R*s.R),o=t.clone().normalize();return(0,i.KM)(o).applyAxisAngle(o,n).multiplyScalar(r)}},"./src/model/physics/pocket.ts":(e,t,n)=>{n.d(t,{Z:()=>l});var r=n("./src/model/ball.ts"),i=n("./src/model/physics/constants.ts"),s=n("./src/utils/utils.ts");function o(e,t){for(var n=0;nthis.radius-i.R){var o=this.pos.clone().sub(e.pos).normalize().setZ(0);n>-i.R/2&&(e.vel.addScaledVector(o,7*i.R*t*i.g),e.rvel.addScaledVector((0,s.KM)(o),7*t*i.g)),0>e.vel.dot(o)&&(e.ballmesh.trace.forceTrace(e.pos),e.vel.x=o.x*e.vel.length()/2,e.vel.y=o.y*e.vel.length()/2)}var a=this.restingDepth(e);n{n.d(t,{X:()=>b});var r=n("./src/view/tablegeometry.ts"),i=n("./src/model/physics/physics.ts"),s=n("./src/view/pocketgeometry.ts"),o=/*#__PURE__*/function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t)}return e=[{key:"bounceAny",value:function(e,n){var s=!(arguments.length>2)||void 0===arguments[2]||arguments[2],o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:i.$8,a=e.futurePosition(n);if(t.willBounceLong(a,s)){var l=a.y>r.P.tableY?-Math.PI/2:Math.PI/2;return t.bounceIn(l,e,o)}if(t.willBounceShort(a,s)){var c=a.x>r.P.tableX?0:Math.PI;return t.bounceIn(c,e,o)}}},{key:"willBounceShort",value:function(e,n){return n?t.willBounceShortSegment(s.f.pockets.pocketNW.knuckleSW.pos.y,s.f.pockets.pocketSW.knuckleNW.pos.y,e):t.willBounceShortSegment(r.P.Y,-r.P.Y,e)}},{key:"willBounceLong",value:function(e,n){return n?t.willBounceLongSegment(s.f.pockets.pocketNW.knuckleNE.pos.x,s.f.pockets.pocketN.knuckleNW.pos.x,e)||t.willBounceLongSegment(s.f.pockets.pocketN.knuckleNE.pos.x,s.f.pockets.pocketNE.knuckleNW.pos.x,e):t.willBounceLongSegment(-r.P.X,r.P.X,e)}},{key:"willBounceLongSegment",value:function(e,t,n){return n.x>e&&n.xr.P.tableY}},{key:"willBounceShortSegment",value:function(e,t,n){return n.y>t&&n.yr.P.tableX}},{key:"bounceIn",value:function(e,t,n){t.ballmesh.trace.forceTrace(t.futurePos);var r=(0,i.QK)(e,t.vel,t.rvel,n);return t.vel.add(r.v),t.rvel.add(r.w),r.v.length()}}],function(e,t){for(var n=0;n100)throw Error("Depth exceeded resolving collisions");this.balls.forEach(function(t){t.update(e)})}},{key:"prepareAdvanceAll",value:function(e){var t=this;return this.pairs.every(function(n){return t.prepareAdvancePair(n.a,n.b,e)})&&this.balls.every(function(n){return t.prepareAdvanceToCushions(n,e)})}},{key:"prepareAdvancePair",value:function(e,t,n){if(u.willCollide(e,t,n)){var r=u.collide(e,t);return this.outcome.push(v.P.collision(e,t,r)),!1}return!0}},{key:"prepareAdvanceToCushions",value:function(e,t){if(!e.onTable())return!0;var n=e.futurePosition(t);if(Math.abs(n.y)1&&void 0!==arguments[1]?arguments[1]:this.cueball;return this.balls.filter(function(e){return e!==t}).some(function(t){return t.pos.distanceTo(e)<2*c.R})}}],t=[{key:"fromSerialised",value:function(e){var t=new n(e.balls.map(function(e){return l.c.fromSerialised(e)}));return t.updateFromSerialised(e),t}}],e&&m(n.prototype,e),t&&m(n,t),n}()},"./src/utils/gltf.ts":(e,t,n)=>{n.d(t,{KP:()=>eR,Ro:()=>eS});var r=n("./node_modules/three/build/three.module.js");let i={POSITION:["byte","byte normalized","unsigned byte","unsigned byte normalized","short","short normalized","unsigned short","unsigned short normalized"],NORMAL:["byte normalized","short normalized"],TANGENT:["byte normalized","short normalized"],TEXCOORD:["byte","byte normalized","unsigned byte","short","short normalized","unsigned short"]};class s{constructor(){this.textureUtils=null,this.pluginCallbacks=[],this.register(function(e){return new y(e)}),this.register(function(e){return new b(e)}),this.register(function(e){return new x(e)}),this.register(function(e){return new T(e)}),this.register(function(e){return new A(e)}),this.register(function(e){return new P(e)}),this.register(function(e){return new g(e)}),this.register(function(e){return new w(e)}),this.register(function(e){return new k(e)}),this.register(function(e){return new R(e)}),this.register(function(e){return new S(e)}),this.register(function(e){return new E(e)}),this.register(function(e){return new O(e)}),this.register(function(e){return new M(e)})}register(e){return -1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return -1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}setTextureUtils(e){return this.textureUtils=e,this}parse(e,t,n,r){let i=new m,s=[];for(let e=0,t=this.pluginCallbacks.length;ee.toBlob(n,t)):("image/jpeg"===t?n=.92:"image/webp"===t&&(n=.8),e.convertToBlob({type:t,quality:n}))}class m{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.extensionsRequired={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter r"+r.sPf}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map},this.textureUtils=null}setPlugins(e){this.plugins=e}setTextureUtils(e){this.textureUtils=e}async writeAsync(e,t,n={}){this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},n),this.options.animations.length>0&&(this.options.trs=!0),await this.processInputAsync(e),await Promise.all(this.pending);let r=this.buffers,i=this.json;n=this.options;let s=this.extensionsUsed,o=this.extensionsRequired,a=new Blob(r,{type:"application/octet-stream"}),l=Object.keys(s),c=Object.keys(o);if(l.length>0&&(i.extensionsUsed=l),c.length>0&&(i.extensionsRequired=c),i.buffers&&i.buffers.length>0&&(i.buffers[0].byteLength=a.size),!0===n.binary){let e=new FileReader;e.readAsArrayBuffer(a),e.onloadend=function(){var n;let r=p(e.result),s=new DataView(new ArrayBuffer(8));s.setUint32(0,r.byteLength,!0),s.setUint32(4,5130562,!0);let o=p((n=JSON.stringify(i),new TextEncoder().encode(n).buffer),32),a=new DataView(new ArrayBuffer(8));a.setUint32(0,o.byteLength,!0),a.setUint32(4,0x4e4f534a,!0);let l=new ArrayBuffer(12),c=new DataView(l);c.setUint32(0,0x46546c67,!0),c.setUint32(4,2,!0);let u=12+a.byteLength+o.byteLength+s.byteLength+r.byteLength;c.setUint32(8,u,!0);let h=new Blob([l,a,o,s,r],{type:"application/octet-stream"}),f=new FileReader;f.readAsArrayBuffer(h),f.onloadend=function(){t(f.result)}}}else if(i.buffers&&i.buffers.length>0){let e=new FileReader;e.readAsDataURL(a),e.onloadend=function(){let n=e.result;i.buffers[0].uri=n,t(i)}}else t(i)}serializeUserData(e,t){if(0===Object.keys(e.userData).length)return;let n=this.options,r=this.extensionsUsed;try{let i=JSON.parse(JSON.stringify(e.userData));if(n.includeCustomExtensions&&i.gltfExtensions){for(let e in void 0===t.extensions&&(t.extensions={}),i.gltfExtensions)t.extensions[e]=i.gltfExtensions[e],r[e]=!0;delete i.gltfExtensions}Object.keys(i).length>0&&(t.extras=i)}catch(t){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+t.message)}}getUID(e,t=!1){if(!1===this.uids.has(e)){let t=new Map;t.set(!0,this.uid++),t.set(!1,this.uid++),this.uids.set(e,t)}return this.uids.get(e).get(t)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;let t=new r.Pq0;for(let n=0,r=e.count;n5e-4)return!1;return!0}createNormalizedNormalAttribute(e){let t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);let n=e.clone(),i=new r.Pq0;for(let e=0,t=n.count;e4?i=e.array[s*e.itemSize+n]:(0===n?i=e.getX(s):1===n?i=e.getY(s):2===n?i=e.getZ(s):3===n&&(i=e.getW(s)),!0===e.normalized&&(i=r.cj9.normalize(i,e.array))),t===o.FLOAT?h.setFloat32(p,i,!0):t===o.INT?h.setInt32(p,i,!0):t===o.UNSIGNED_INT?h.setUint32(p,i,!0):t===o.SHORT?h.setInt16(p,i,!0):t===o.UNSIGNED_SHORT?h.setUint16(p,i,!0):t===o.BYTE?h.setInt8(p,i):t===o.UNSIGNED_BYTE&&h.setUint8(p,i),p+=a}p%c!=0&&(p+=c-p%c)}let d={buffer:this.processBuffer(h.buffer),byteOffset:this.byteOffset,byteLength:u};return void 0!==s&&(d.target=s),s===o.ARRAY_BUFFER&&(d.byteStride=c),this.byteOffset+=u,l.bufferViews.push(d),{id:l.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){let t=this,n=t.json;return n.bufferViews||(n.bufferViews=[]),new Promise(function(r){let i=new FileReader;i.readAsArrayBuffer(e),i.onloadend=function(){let e=p(i.result),s={buffer:t.processBuffer(e),byteOffset:t.byteOffset,byteLength:e.byteLength};t.byteOffset+=e.byteLength,r(n.bufferViews.push(s)-1)}})}processAccessor(e,t,n,i){let s,a;let l=this.json;if(e.array.constructor===Float32Array)s=o.FLOAT;else if(e.array.constructor===Int32Array)s=o.INT;else if(e.array.constructor===Uint32Array)s=o.UNSIGNED_INT;else if(e.array.constructor===Int16Array)s=o.SHORT;else if(e.array.constructor===Uint16Array)s=o.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)s=o.BYTE;else if(e.array.constructor===Uint8Array)s=o.UNSIGNED_BYTE;else throw Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+e.array.constructor.name);if(void 0===n&&(n=0),(void 0===i||i===1/0)&&(i=e.count),0===i)return null;let c=function(e,t,n){let i={min:Array(e.itemSize).fill(Number.POSITIVE_INFINITY),max:Array(e.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let s=t;s4?n=e.array[s*e.itemSize+t]:(0===t?n=e.getX(s):1===t?n=e.getY(s):2===t?n=e.getZ(s):3===t&&(n=e.getW(s)),!0===e.normalized&&(n=r.cj9.normalize(n,e.array))),i.min[t]=Math.min(i.min[t],n),i.max[t]=Math.max(i.max[t],n)}return i}(e,n,i);void 0!==t&&(a=e===t.index?o.ELEMENT_ARRAY_BUFFER:o.ARRAY_BUFFER);let u=this.processBufferView(e,s,n,i,a),h={bufferView:u.id,byteOffset:u.byteOffset,componentType:s,count:i,max:c.max,min:c.min,type:{1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"}[e.itemSize]};return!0===e.normalized&&(h.normalized=!0),l.accessors||(l.accessors=[]),l.accessors.push(h)-1}processImage(e,t,n,i="image/png"){if(null!==e){let s=this,o=s.cache,a=s.json,l=s.options,c=s.pending;o.images.has(e)||o.images.set(e,{});let u=o.images.get(e),h=i+":flipY/"+n.toString();if(void 0!==u[h])return u[h];a.images||(a.images=[]);let f={mimeType:i},p=d();p.width=Math.min(e.width,l.maxTextureSize),p.height=Math.min(e.height,l.maxTextureSize);let m=p.getContext("2d",{willReadFrequently:!0});if(!0===n&&(m.translate(0,p.height),m.scale(1,-1)),void 0!==e.data){t!==r.GWd&&console.error("GLTFExporter: Only RGBAFormat is supported.",t),(e.width>l.maxTextureSize||e.height>l.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);let n=new Uint8ClampedArray(e.height*e.width*4);for(let t=0;ts.processBufferViewImage(e)).then(e=>{f.bufferView=e})):void 0!==p.toDataURL?f.uri=p.toDataURL(i):c.push(v(p,i).then(e=>new FileReader().readAsDataURL(e)).then(e=>{f.uri=e}));let y=a.images.push(f)-1;return u[h]=y,y}throw Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(e){let t=this.json;t.samplers||(t.samplers=[]);let n={magFilter:l[e.magFilter],minFilter:l[e.minFilter],wrapS:l[e.wrapS],wrapT:l[e.wrapT]};return t.samplers.push(n)-1}async processTextureAsync(e){let t=this.options,n=this.cache,i=this.json;if(n.textures.has(e))return n.textures.get(e);i.textures||(i.textures=[]),e instanceof r.FvD&&(e=await this.decompressTextureAsync(e,t.maxTextureSize));let s=e.userData.mimeType;"image/webp"===s&&(s="image/png");let o={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,s)};e.name&&(o.name=e.name),await this._invokeAllAsync(async function(t){t.writeTexture&&await t.writeTexture(e,o)});let a=i.textures.push(o)-1;return n.textures.set(e,a),a}async processMaterialAsync(e){let t=this.cache,n=this.json;if(t.materials.has(e))return t.materials.get(e);if(e.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;n.materials||(n.materials=[]);let i={pbrMetallicRoughness:{}};!0!==e.isMeshStandardMaterial&&!0!==e.isMeshBasicMaterial&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");let s=e.color.toArray().concat([e.opacity]);if(h(s,[1,1,1,1])||(i.pbrMetallicRoughness.baseColorFactor=s),e.isMeshStandardMaterial?(i.pbrMetallicRoughness.metallicFactor=e.metalness,i.pbrMetallicRoughness.roughnessFactor=e.roughness):(i.pbrMetallicRoughness.metallicFactor=0,i.pbrMetallicRoughness.roughnessFactor=1),e.metalnessMap||e.roughnessMap){let t=await this.buildMetalRoughTextureAsync(e.metalnessMap,e.roughnessMap),n={index:await this.processTextureAsync(t),texCoord:t.channel};this.applyTextureTransform(n,t),i.pbrMetallicRoughness.metallicRoughnessTexture=n}if(e.map){let t={index:await this.processTextureAsync(e.map),texCoord:e.map.channel};this.applyTextureTransform(t,e.map),i.pbrMetallicRoughness.baseColorTexture=t}if(e.emissive){let t=e.emissive;if(Math.max(t.r,t.g,t.b)>0&&(i.emissiveFactor=e.emissive.toArray()),e.emissiveMap){let t={index:await this.processTextureAsync(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(t,e.emissiveMap),i.emissiveTexture=t}}if(e.normalMap){let t={index:await this.processTextureAsync(e.normalMap),texCoord:e.normalMap.channel};e.normalScale&&1!==e.normalScale.x&&(t.scale=e.normalScale.x),this.applyTextureTransform(t,e.normalMap),i.normalTexture=t}if(e.aoMap){let t={index:await this.processTextureAsync(e.aoMap),texCoord:e.aoMap.channel};1!==e.aoMapIntensity&&(t.strength=e.aoMapIntensity),this.applyTextureTransform(t,e.aoMap),i.occlusionTexture=t}e.transparent?i.alphaMode="BLEND":e.alphaTest>0&&(i.alphaMode="MASK",i.alphaCutoff=e.alphaTest),e.side===r.$EB&&(i.doubleSided=!0),""!==e.name&&(i.name=e.name),this.serializeUserData(e,i),await this._invokeAllAsync(async function(t){t.writeMaterialAsync&&await t.writeMaterialAsync(e,i)});let o=n.materials.push(i)-1;return t.materials.set(e,o),o}async processMeshAsync(e){let t;let n=this.cache,i=this.json,a=[e.geometry.uuid];if(Array.isArray(e.material))for(let t=0,n=e.material.length;t0){let t=[],r=[],i={};if(void 0!==e.morphTargetDictionary)for(let t in e.morphTargetDictionary)i[e.morphTargetDictionary[t]]=t;for(let s=0;s0&&(u.extras={},u.extras.targetNames=r)}let y=Array.isArray(e.material);if(y&&0===c.groups.length)return null;let b=!1;if(y&&null===c.index){let e=[];for(let t=0,n=c.attributes.position.count;t0&&(r.targets=p),null!==c.index){let t=this.getUID(c.index);(void 0!==w[e].start||void 0!==w[e].count)&&(t+=":"+w[e].start+":"+w[e].count),n.attributes.has(t)?r.indices=n.attributes.get(t):(r.indices=this.processAccessor(c.index,c,w[e].start,w[e].count),n.attributes.set(t,r.indices)),null===r.indices&&delete r.indices}let i=await this.processMaterialAsync(g[w[e].materialIndex]);null!==i&&(r.material=i),f.push(r)}!0===b&&c.setIndex(null),u.primitives=f,i.meshes||(i.meshes=[]),await this._invokeAllAsync(function(t){t.writeMesh&&t.writeMesh(e,u)});let k=i.meshes.push(u)-1;return n.meshes.set(l,k),k}detectMeshQuantization(e,t){let n;if(this.extensionsUsed[a])return;switch(t.array.constructor){case Int8Array:n="byte";break;case Uint8Array:n="unsigned byte";break;case Int16Array:n="short";break;case Uint16Array:n="unsigned short";break;default:return}t.normalized&&(n+=" normalized");let r=e.split("_",1)[0];i[r]&&i[r].includes(n)&&(this.extensionsUsed[a]=!0,this.extensionsRequired[a]=!0)}processCamera(e){let t=this.json;t.cameras||(t.cameras=[]);let n=e.isOrthographicCamera,i={type:n?"orthographic":"perspective"};return n?i.orthographic={xmag:2*e.right,ymag:2*e.top,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:i.perspective={aspectRatio:e.aspect,yfov:r.cj9.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},""!==e.name&&(i.name=e.type),t.cameras.push(i)-1}processAnimation(e,t){let n=this.json,i=this.nodeMap;n.animations||(n.animations=[]);let o=(e=s.Utils.mergeMorphTargetTracks(e.clone(),t)).tracks,a=[],l=[];for(let e=0;e0){let t=[];for(let r=0,i=e.children.length;r0&&(i.children=t)}await this._invokeAllAsync(function(t){t.writeNode&&t.writeNode(e,i)});let s=t.nodes.push(i)-1;return r.set(e,s),s}async processSceneAsync(e){let t=this.json,n=this.options;t.scenes||(t.scenes=[],t.scene=0);let r={};""!==e.name&&(r.name=e.name),t.scenes.push(r);let i=[];for(let t=0,r=e.children.length;t0&&(r.nodes=i),this.serializeUserData(e,r)}async processObjectsAsync(e){let t=new r.Z58;t.name="AuxScene";for(let n=0;n0&&await this.processObjectsAsync(n);for(let e=0;e0&&(s.range=e.distance)):e.isSpotLight&&(s.type="spot",e.distance>0&&(s.range=e.distance),s.spot={},s.spot.innerConeAngle=(1-e.penumbra)*e.angle,s.spot.outerConeAngle=e.angle),void 0!==e.decay&&2!==e.decay&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),e.target&&(e.target.parent!==e||0!==e.target.position.x||0!==e.target.position.y||-1!==e.target.position.z)&&console.warn("THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."),i[this.name]||(r.extensions=r.extensions||{},r.extensions[this.name]={lights:[]},i[this.name]=!0);let o=r.extensions[this.name].lights;o.push(s),t.extensions=t.extensions||{},t.extensions[this.name]={light:o.length-1}}}class b{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}async writeMaterialAsync(e,t){if(!e.isMeshBasicMaterial)return;let n=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},n[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}}class g{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||0===e.clearcoat)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.clearcoatFactor=e.clearcoat,e.clearcoatMap){let t={index:await n.processTextureAsync(e.clearcoatMap),texCoord:e.clearcoatMap.channel};n.applyTextureTransform(t,e.clearcoatMap),i.clearcoatTexture=t}if(i.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){let t={index:await n.processTextureAsync(e.clearcoatRoughnessMap),texCoord:e.clearcoatRoughnessMap.channel};n.applyTextureTransform(t,e.clearcoatRoughnessMap),i.clearcoatRoughnessTexture=t}if(e.clearcoatNormalMap){let t={index:await n.processTextureAsync(e.clearcoatNormalMap),texCoord:e.clearcoatNormalMap.channel};1!==e.clearcoatNormalScale.x&&(t.scale=e.clearcoatNormalScale.x),n.applyTextureTransform(t,e.clearcoatNormalMap),i.clearcoatNormalTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class w{constructor(e){this.writer=e,this.name="KHR_materials_dispersion"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||0===e.dispersion)return;let n=this.writer.extensionsUsed,r={};r.dispersion=e.dispersion,t.extensions=t.extensions||{},t.extensions[this.name]=r,n[this.name]=!0}}class k{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||0===e.iridescence)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.iridescenceFactor=e.iridescence,e.iridescenceMap){let t={index:await n.processTextureAsync(e.iridescenceMap),texCoord:e.iridescenceMap.channel};n.applyTextureTransform(t,e.iridescenceMap),i.iridescenceTexture=t}if(i.iridescenceIor=e.iridescenceIOR,i.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],i.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){let t={index:await n.processTextureAsync(e.iridescenceThicknessMap),texCoord:e.iridescenceThicknessMap.channel};n.applyTextureTransform(t,e.iridescenceThicknessMap),i.iridescenceThicknessTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class x{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.transmissionFactor=e.transmission,e.transmissionMap){let t={index:await n.processTextureAsync(e.transmissionMap),texCoord:e.transmissionMap.channel};n.applyTextureTransform(t,e.transmissionMap),i.transmissionTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class T{constructor(e){this.writer=e,this.name="KHR_materials_volume"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.thicknessFactor=e.thickness,e.thicknessMap){let t={index:await n.processTextureAsync(e.thicknessMap),texCoord:e.thicknessMap.channel};n.applyTextureTransform(t,e.thicknessMap),i.thicknessTexture=t}e.attenuationDistance!==1/0&&(i.attenuationDistance=e.attenuationDistance),i.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class A{constructor(e){this.writer=e,this.name="KHR_materials_ior"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||1.5===e.ior)return;let n=this.writer.extensionsUsed,r={};r.ior=e.ior,t.extensions=t.extensions||{},t.extensions[this.name]=r,n[this.name]=!0}}class P{constructor(e){this.writer=e,this.name="KHR_materials_specular"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||1===e.specularIntensity&&e.specularColor.equals(u)&&!e.specularIntensityMap&&!e.specularColorMap)return;let n=this.writer,r=n.extensionsUsed,i={};if(e.specularIntensityMap){let t={index:await n.processTextureAsync(e.specularIntensityMap),texCoord:e.specularIntensityMap.channel};n.applyTextureTransform(t,e.specularIntensityMap),i.specularTexture=t}if(e.specularColorMap){let t={index:await n.processTextureAsync(e.specularColorMap),texCoord:e.specularColorMap.channel};n.applyTextureTransform(t,e.specularColorMap),i.specularColorTexture=t}i.specularFactor=e.specularIntensity,i.specularColorFactor=e.specularColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class R{constructor(e){this.writer=e,this.name="KHR_materials_sheen"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||0==e.sheen)return;let n=this.writer,r=n.extensionsUsed,i={};if(e.sheenRoughnessMap){let t={index:await n.processTextureAsync(e.sheenRoughnessMap),texCoord:e.sheenRoughnessMap.channel};n.applyTextureTransform(t,e.sheenRoughnessMap),i.sheenRoughnessTexture=t}if(e.sheenColorMap){let t={index:await n.processTextureAsync(e.sheenColorMap),texCoord:e.sheenColorMap.channel};n.applyTextureTransform(t,e.sheenColorMap),i.sheenColorTexture=t}i.sheenRoughnessFactor=e.sheenRoughness,i.sheenColorFactor=e.sheenColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class S{constructor(e){this.writer=e,this.name="KHR_materials_anisotropy"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||0==e.anisotropy)return;let n=this.writer,r=n.extensionsUsed,i={};if(e.anisotropyMap){let t={index:await n.processTextureAsync(e.anisotropyMap)};n.applyTextureTransform(t,e.anisotropyMap),i.anisotropyTexture=t}i.anisotropyStrength=e.anisotropy,i.anisotropyRotation=e.anisotropyRotation,t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class E{constructor(e){this.writer=e,this.name="KHR_materials_emissive_strength"}async writeMaterialAsync(e,t){if(!e.isMeshStandardMaterial||1===e.emissiveIntensity)return;let n=this.writer.extensionsUsed,r={};r.emissiveStrength=e.emissiveIntensity,t.extensions=t.extensions||{},t.extensions[this.name]=r,n[this.name]=!0}}class O{constructor(e){this.writer=e,this.name="EXT_materials_bump"}async writeMaterialAsync(e,t){if(!e.isMeshStandardMaterial||1===e.bumpScale&&!e.bumpMap)return;let n=this.writer,r=n.extensionsUsed,i={};if(e.bumpMap){let t={index:await n.processTextureAsync(e.bumpMap),texCoord:e.bumpMap.channel};n.applyTextureTransform(t,e.bumpMap),i.bumpTexture=t}i.bumpFactor=e.bumpScale,t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class M{constructor(e){this.writer=e,this.name="EXT_mesh_gpu_instancing"}writeNode(e,t){if(!e.isInstancedMesh)return;let n=this.writer,i=new Float32Array(3*e.count),s=new Float32Array(4*e.count),o=new Float32Array(3*e.count),a=new r.kn4,l=new r.Pq0,c=new r.PTz,u=new r.Pq0;for(let t=0;tMath.abs(e.times[0]-t))return 0;i[0]=t,i.set(e.times,1),s.set(o.evaluate(t),0),s.set(e.values,r),n=0}else if(t>e.times[e.times.length-1]){if(.001>Math.abs(e.times[e.times.length-1]-t))return e.times.length-1;i[i.length-1]=t,i.set(e.times,0),s.set(e.values,0),s.set(o.evaluate(t),e.values.length),n=i.length-1}else for(let a=0;aMath.abs(e.times[a]-t))return a;if(e.times[a]t){i.set(e.times.slice(0,a+1),0),i[a+1]=t,i.set(e.times.slice(a+1),a+2),s.set(e.values.slice(0,(a+1)*r),0),s.set(o.evaluate(t),(a+1)*r),s.set(e.values.slice((a+1)*r),(a+2)*r),n=a+1;break}}return e.times=i,e.values=s,n},mergeMorphTargetTracks:function(e,t){let n=[],i={},s=e.tracks;for(let e=0;e=2.0 are supported."));return}let l=new ex(i,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e=0&&void 0===o[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}l.setExtensions(s),l.setPlugins(o),l.parse(n,r)}parseAsync(e,t){let n=this;return new Promise(function(r,i){n.parse(e,t,r,i)})}}function C(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}let j={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class B{constructor(e){this.parser=e,this.name=j.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n=0))return null;throw Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures")}return t.loadTextureImage(e,i.source,s)}}class W{constructor(e){this.parser=e,this.name=j.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let s=i.extensions[t],o=r.images[s.source],a=n.textureLoader;if(o.uri){let e=n.options.manager.getHandler(o.uri);null!==e&&(a=e)}return this.detectSupport().then(function(i){if(i)return n.loadTextureImage(e,s.source,a);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){let t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}})),this.isSupported}}class Q{constructor(e){this.parser=e,this.name=j.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let s=i.extensions[t],o=r.images[s.source],a=n.textureLoader;if(o.uri){let e=n.options.manager.getHandler(o.uri);null!==e&&(a=e)}return this.detectSupport().then(function(i){if(i)return n.loadTextureImage(e,s.source,a);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){let t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(1===t.height)}})),this.isSupported}}class Z{constructor(e){this.name=j.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(!n.extensions||!n.extensions[this.name])return null;{let e=n.extensions[this.name],r=this.parser.getDependency("buffer",e.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(!(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0))return null;throw Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files")}return r.then(function(t){let n=e.byteOffset||0,r=e.byteLength||0,s=e.count,o=e.byteStride,a=new Uint8Array(t,n,r);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(s,o,a,e.mode,e.filter).then(function(e){return e.buffer}):i.ready.then(function(){let t=new ArrayBuffer(s*o);return i.decodeGltfBuffer(new Uint8Array(t),s,o,a,e.mode,e.filter),t})})}}}class J{constructor(e){this.name=j.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||void 0===n.mesh)return null;for(let e of t.meshes[n.mesh].primitives)if(e.mode!==el.TRIANGLES&&e.mode!==el.TRIANGLE_STRIP&&e.mode!==el.TRIANGLE_FAN&&void 0!==e.mode)return null;let i=n.extensions[this.name].attributes,s=[],o={};for(let e in i)s.push(this.parser.getDependency("accessor",i[e]).then(t=>(o[e]=t,o[e])));return s.length<1?null:(s.push(this.parser.createNodeMesh(e)),Promise.all(s).then(e=>{let t=e.pop(),n=t.isGroup?t.children:[t],i=e[0].count,s=[];for(let e of n){let t=new r.kn4,n=new r.Pq0,a=new r.PTz,l=new r.Pq0(1,1,1),c=new r.ZLX(e.geometry,e.material,i);for(let e=0;e-1)?e.match(/Firefox\/([0-9]+)\./)[1]:-1}"undefined"==typeof createImageBitmap||n&&i<17||s&&o<98?this.textureLoader=new r.Tap(this.options.manager):this.textureLoader=new r.Kzg(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new r.Y9S(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,r=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(e){return e._markDefs&&e._markDefs()}),Promise.all(this._invokeAll(function(e){return e.beforeRoot&&e.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(t){let s={scene:t[0][r.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:r.asset,parser:n,userData:{}};return ey(i,s,r),eb(s,r),Promise.all(n._invokeAll(function(e){return e.afterRoot&&e.afterRoot(s)})).then(function(){for(let e of s.scenes)e.updateMatrixWorld();e(s)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,r=t.length;n{let n=this.associations.get(e);for(let[r,s]of(null!=n&&this.associations.set(t,n),e.children.entries()))i(s,t.children[r])};return i(n,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n=2&&o.setY(t,f[e*l+1]),l>=3&&o.setZ(t,f[e*l+2]),l>=4&&o.setW(t,f[e*l+3]),l>=5)throw Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}o.normalized=d}return o})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e].source,i=t.images[r],s=this.textureLoader;if(i.uri){let e=n.manager.getHandler(i.uri);null!==e&&(s=e)}return this.loadTextureImage(e,r,s)}loadTextureImage(e,t,n){let i=this,s=this.json,o=s.textures[e],a=s.images[t],l=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[l])return this.textureCache[l];let c=this.loadImageSource(t,n).then(function(t){t.flipY=!1,t.name=o.name||a.name||"",""===t.name&&"string"==typeof a.uri&&!1===a.uri.startsWith("data:image/")&&(t.name=a.uri);let n=(s.samplers||{})[o.sampler]||{};return t.magFilter=eu[n.magFilter]||r.k6q,t.minFilter=eu[n.minFilter]||r.$_I,t.wrapS=eh[n.wrapS]||r.GJx,t.wrapT=eh[n.wrapT]||r.GJx,t.generateMipmaps=!t.isCompressedTexture&&t.minFilter!==r.hxR&&t.minFilter!==r.k6q,i.associations.set(t,{textures:e}),t}).catch(function(){return null});return this.textureCache[l]=c,c}loadImageSource(e,t){let n=this.json,i=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then(e=>e.clone());let s=n.images[e],o=self.URL||self.webkitURL,a=s.uri||"",l=!1;if(void 0!==s.bufferView)a=this.getDependency("bufferView",s.bufferView).then(function(e){l=!0;let t=new Blob([e],{type:s.mimeType});return a=o.createObjectURL(t)});else if(void 0===s.uri)throw Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let c=Promise.resolve(a).then(function(e){return new Promise(function(n,s){let o=n;!0===t.isImageBitmapLoader&&(o=function(e){let t=new r.gPd(e);t.needsUpdate=!0,n(t)}),t.load(r.r6x.resolveURL(e,i.path),o,void 0,s)})}).then(function(e){var t;return!0===l&&o.revokeObjectURL(a),eb(e,s),e.userData.mimeType=s.mimeType||((t=s.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":t.search(/\.ktx2($|\?)/i)>0||0===t.search(/^data\:image\/ktx2/)?"image/ktx2":"image/png"),e}).catch(function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),e});return this.sourceCache[e]=c,c}assignTexture(e,t,n,r){let i=this;return this.getDependency("texture",n.index).then(function(s){if(!s)return null;if(void 0!==n.texCoord&&n.texCoord>0&&((s=s.clone()).channel=n.texCoord),i.extensions[j.KHR_TEXTURE_TRANSFORM]){let e=void 0!==n.extensions?n.extensions[j.KHR_TEXTURE_TRANSFORM]:void 0;if(e){let t=i.associations.get(s);s=i.extensions[j.KHR_TEXTURE_TRANSFORM].extendTexture(s,e),i.associations.set(s,t)}}return void 0!==r&&(s.colorSpace=r),e[t]=s,s})}assignFinalMaterial(e){let t=e.geometry,n=e.material,i=void 0===t.attributes.tangent,s=void 0!==t.attributes.color,o=void 0===t.attributes.normal;if(e.isPoints){let e="PointsMaterial:"+n.uuid,t=this.cache.get(e);t||(t=new r.BH$,r.imn.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){let e="LineBasicMaterial:"+n.uuid,t=this.cache.get(e);t||(t=new r.mrM,r.imn.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,this.cache.add(e,t)),n=t}if(i||s||o){let e="ClonedMaterial:"+n.uuid+":";i&&(e+="derivative-tangents:"),s&&(e+="vertex-colors:"),o&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=n.clone(),s&&(t.vertexColors=!0),o&&(t.flatShading=!0),i&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}e.material=n}getMaterialType(){return r._4j}loadMaterial(e){let t;let n=this,i=this.json,s=this.extensions,o=i.materials[e],a={},l=o.extensions||{},c=[];if(l[j.KHR_MATERIALS_UNLIT]){let e=s[j.KHR_MATERIALS_UNLIT];t=e.getMaterialType(),c.push(e.extendParams(a,o,n))}else{let i=o.pbrMetallicRoughness||{};if(a.color=new r.Q1f(1,1,1),a.opacity=1,Array.isArray(i.baseColorFactor)){let e=i.baseColorFactor;a.color.setRGB(e[0],e[1],e[2],r.Zr2),a.opacity=e[3]}void 0!==i.baseColorTexture&&c.push(n.assignTexture(a,"map",i.baseColorTexture,r.er$)),a.metalness=void 0!==i.metallicFactor?i.metallicFactor:1,a.roughness=void 0!==i.roughnessFactor?i.roughnessFactor:1,void 0!==i.metallicRoughnessTexture&&(c.push(n.assignTexture(a,"metalnessMap",i.metallicRoughnessTexture)),c.push(n.assignTexture(a,"roughnessMap",i.metallicRoughnessTexture))),t=this._invokeOne(function(t){return t.getMaterialType&&t.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,a)})))}!0===o.doubleSided&&(a.side=r.$EB);let u=o.alphaMode||em.OPAQUE;if(u===em.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,u===em.MASK&&(a.alphaTest=void 0!==o.alphaCutoff?o.alphaCutoff:.5)),void 0!==o.normalTexture&&t!==r.V9B&&(c.push(n.assignTexture(a,"normalMap",o.normalTexture)),a.normalScale=new r.I9Y(1,1),void 0!==o.normalTexture.scale)){let e=o.normalTexture.scale;a.normalScale.set(e,e)}if(void 0!==o.occlusionTexture&&t!==r.V9B&&(c.push(n.assignTexture(a,"aoMap",o.occlusionTexture)),void 0!==o.occlusionTexture.strength&&(a.aoMapIntensity=o.occlusionTexture.strength)),void 0!==o.emissiveFactor&&t!==r.V9B){let e=o.emissiveFactor;a.emissive=new r.Q1f().setRGB(e[0],e[1],e[2],r.Zr2)}return void 0!==o.emissiveTexture&&t!==r.V9B&&c.push(n.assignTexture(a,"emissiveMap",o.emissiveTexture,r.er$)),Promise.all(c).then(function(){let r=new t(a);return o.name&&(r.name=o.name),eb(r,o),n.associations.set(r,{materials:e}),o.extensions&&ey(s,r,o),r})}createUniqueName(e){let t=r.Nwf.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,n=this.extensions,i=this.primitiveCache,s=[];for(let o=0,a=e.length;o0&&function(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let n=0,r=t.weights.length;n1?new r.YJl:1===t.length?t[0]:new r.B69)!==t[0])for(let e=0,n=t.length;e{let t=new Map;for(let[e,n]of i.associations)(e instanceof r.imn||e instanceof r.gPd)&&t.set(e,n);return e.traverse(e=>{let n=i.associations.get(e);null!=n&&t.set(e,n)}),t})(s),s})}_createAnimationTracks(e,t,n,i,s){let o;let a=[],l=e.name?e.name:e.uuid,c=[];switch(ed[s.path]===ed.weights?e.traverse(function(e){e.morphTargetInfluences&&c.push(e.name?e.name:e.uuid)}):c.push(l),ed[s.path]){case ed.weights:o=r.Hit;break;case ed.rotation:o=r.MBL;break;case ed.position:case ed.scale:o=r.RiT;break;default:o=1===n.itemSize?r.Hit:r.RiT}let u=void 0!==i.interpolation?ev[i.interpolation]:r.PJ3,h=this._getArrayFromAccessor(n);for(let e=0,n=c.length;e{n.d(t,{m:()=>c});var r=n("./src/model/ball.ts"),i=n("./src/view/tablegeometry.ts"),s=n("./node_modules/three/build/three.module.js"),o=n("./src/utils/utils.ts"),a=n("./src/model/physics/constants.ts");function l(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var c=/*#__PURE__*/function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t)}return e=[{key:"jitter",value:function(e){return(0,o.ld)(e.clone().add(new s.Pq0(t.noise*(Math.random()-.5),t.noise*(Math.random()-.5),0)))}},{key:"cueBall",value:function(e){return new r.c(t.jitter(e),0xfaebd7)}},{key:"diamond",value:function(){var e=new s.Pq0(i.P.tableX/2,0,0),n=[];return n.push(t.cueBall(t.spot)),n.push(new r.c(t.jitter(e),0xe0de36)),e.add(t.diagonal),n.push(new r.c(t.jitter(e),0xff9d00)),e.sub(t.across),n.push(new r.c(t.jitter(e),5380369)),e.add(t.diagonal),n.push(new r.c(t.jitter(e),5853696)),e.sub(t.across),n.push(new r.c(t.jitter(e),0xff0000)),e.addScaledVector(t.across,2),n.push(new r.c(t.jitter(e),328965)),e.add(t.diagonal).sub(t.across),n.push(new r.c(t.jitter(e),685250)),e.sub(t.across),n.push(new r.c(t.jitter(e),553728)),e.add(t.diagonal),n.push(new r.c(t.jitter(e),4063388)),n}},{key:"triangle",value:function(){var e=t.trianglePositions(),n=t.cueBall(t.spot),i=e.map(function(e){return new r.c(t.jitter(e))});return i.unshift(n),i.slice(0,5)}},{key:"trianglePositions",value:function(){var e=[],t=new s.Pq0(i.P.X/2,0,0);return e.push((0,o.t6)(t)),t.add(this.diagonal),e.push((0,o.t6)(t)),t.sub(this.across),e.push((0,o.t6)(t)),t.add(this.diagonal),e.push((0,o.t6)(t)),t.sub(this.across),e.push((0,o.t6)(t)),t.addScaledVector(this.across,2),e.push((0,o.t6)(t)),t.add(this.diagonal),e.push((0,o.t6)(t)),t.sub(this.across),e.push((0,o.t6)(t)),t.sub(this.across),e.push((0,o.t6)(t)),t.sub(this.across),e.push((0,o.t6)(t)),t.add(this.diagonal).sub(this.across),e.push((0,o.t6)(t)),t.add(this.across),e.push((0,o.t6)(t)),t.add(this.across),e.push((0,o.t6)(t)),t.add(this.across),e.push((0,o.t6)(t)),t.add(this.across),e.push((0,o.t6)(t)),e}},{key:"rerack",value:function(e,n){var i=t.trianglePositions(),s=i.shift();n.balls.filter(function(e){return e!==n.cueball}).filter(function(t){return t!==e}).forEach(function(e){e.pos.copy(t.jitter(i.shift())),e.state=r.U.Stationary}),n.overlapsAny(e.pos,e)&&e.pos.copy(s),n.overlapsAny(n.cueball.pos)&&n.cueball.pos.copy(t.spot)}},{key:"three",value:function(){var e=[],n=i.P.X/2,o=i.P.Y/4;return e.push(t.cueBall(t.jitter(new s.Pq0(-n,-o,0)))),e.push(new r.c(t.jitter(new s.Pq0(-n,0,0)),0xe0de36)),e.push(new r.c(t.jitter(new s.Pq0(n,0,0)),0xff0000)),e}},{key:"snooker",value:function(){var e=[],n=i.P.Y/4;e.push(t.cueBall(t.jitter(new s.Pq0(t.baulk,-(.5*n),0))));var o=t.snookerColourPositions();return e.push(new r.c(t.jitter(o[0]),0xeede36)),e.push(new r.c(t.jitter(o[1]),824932)),e.push(new r.c(t.jitter(o[2]),0xbd723a)),e.push(new r.c(t.jitter(o[3]),558062)),e.push(new r.c(t.jitter(o[4]),0xffaacc)),e.push(new r.c(t.jitter(o[5]),65793)),t.trianglePositions().slice(0,15).forEach(function(n){e.push(new r.c(t.jitter(n.add(t.down)),0xee0000))}),e}},{key:"snookerColourPositions",value:function(){var e=i.P.X/2,n=i.P.X-2*i.P.X/11,r=[];return r.push(new s.Pq0(t.baulk,-t.sixth,0)),r.push(new s.Pq0(t.baulk,t.sixth,0)),r.push(new s.Pq0(t.baulk,0,0)),r.push(new s.Pq0(0,0,0)),r.push(new s.Pq0(e,0,0)),r.push(new s.Pq0(n,0,0)),r}}],function(e,t){for(var n=0;n{n.d(t,{k:()=>a});var r=n("./src/model/ball.ts"),i=n("./src/view/tablegeometry.ts"),s=n("./src/model/physics/constants.ts"),o=n("./src/utils/rack.ts"),a=/*#__PURE__*/function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t)}return e=[{key:"respot",value:function(e,n){var i=o.m.snookerColourPositions();return i.push(i[e.id-1]),i.reverse(),i.some(function(t){return!n.overlapsAny(t,e)&&(e.pos.copy(t),e.state=r.U.Stationary,!0)})||t.respotBehind(i[0],e,n),e}},{key:"respotBehind",value:function(e,t,n){for(var o=e.clone();o.x-i.P.tableX&&n.overlapsAny(o,t);)o.x-=s.R/8;t.pos.copy(o),t.state=r.U.Stationary}},{key:"closest",value:function(e,t){var n=t.filter(function(e){return e.onTable()}).filter(function(t){return t!==e});if(0!==n.length){var r=function(t){return e.pos.distanceTo(t.pos)};return n.reduce(function(e,t){return r(e){n.d(t,{Dz:()=>p,KM:()=>l,ld:()=>v,rq:()=>f,t6:()=>o,up:()=>s,v_:()=>i,xb:()=>u});var r=n("./node_modules/three/build/three.module.js"),i=new r.Pq0(0,0,0),s=new r.Pq0(0,0,1);function o(e){return new r.Pq0(e.x,e.y,e.z)}var a=new r.Pq0;function l(e){return a.copy(s).cross(e)}var c=new r.Pq0;function u(e){return c.copy(e).normalize()}var h=new r.Pq0;function f(e,t){return 0>=h.copy(e).add(t).dot(e)}function p(e){return new r.Pq0(1,0,0).applyAxisAngle(s,e)}function d(e){return Math.sign(e)*Math.floor((Math.abs(e)+Number.EPSILON)*1e4)/1e4}function v(e){return e.x=d(e.x),e.y=d(e.y),e.z=d(e.z),e}},"./src/view/assets.ts":(e,t,n)=>{n.d(t,{s:()=>m});var r=n("./src/controller/rules/rulefactory.ts"),i=n("./src/utils/gltf.ts"),s=n("./node_modules/three/build/three.module.js");function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var a=/*#__PURE__*/function(){var e;function t(e){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),o(this,"listener",void 0),o(this,"audioLoader",void 0),o(this,"ballcollision",void 0),o(this,"cue",void 0),o(this,"cushion",void 0),o(this,"pot",void 0),o(this,"success",void 0),o(this,"lastOutcomeTime",0),o(this,"loadAssets",void 0),this.loadAssets=e,e&&(this.listener=new s.Pf$,this.audioLoader=new s.Am1,this.ballcollision=new s.fP5(this.listener),this.load("sounds/ballcollision.ogg",this.ballcollision),this.cue=new s.fP5(this.listener),this.load("sounds/cue.ogg",this.cue),this.cushion=new s.fP5(this.listener),this.load("sounds/cushion.ogg",this.cushion),this.pot=new s.fP5(this.listener),this.load("sounds/pot.ogg",this.pot),this.success=new s.fP5(this.listener),this.load("sounds/success.ogg",this.success))}return e=[{key:"addCameraToListener",value:function(e){e.add(this.listener)}},{key:"load",value:function(e,t){this.audioLoader.load(e,function(e){t.setBuffer(e),t.setLoop(!1)},function(e){},function(e){})}},{key:"play",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(this.loadAssets){var r,i,o=s.UtX.getContext();if((null==o?void 0:o.state)==="suspended"){(null===(i=navigator)||void 0===i?void 0:null===(r=i.userActivation)||void 0===r?void 0:r.hasBeenActive)&&o.resume();return}e.setVolume(t),e.isPlaying&&e.stop(),e.play(s.cj9.randFloat(0,.01)),e.setDetune(n)}}},{key:"outcomeToSound",value:function(e){"Collision"===e.type&&this.play(this.ballcollision,e.incidentSpeed/80,5*e.incidentSpeed),"Pot"===e.type&&this.play(this.pot,e.incidentSpeed/10,-1e3+10*e.incidentSpeed),"Cushion"===e.type&&this.play(this.cushion,e.incidentSpeed/70),"Hit"===e.type&&this.play(this.cue,e.incidentSpeed/30)}},{key:"processOutcomes",value:function(e){var t=this;e.every(function(e){return!(e.timestamp>t.lastOutcomeTime)||(t.lastOutcomeTime=e.timestamp,t.outcomeToSound(e),!1)})}},{key:"playNotify",value:function(){this.play(this.pot,1)}},{key:"playSuccess",value:function(e){this.play(this.success,.1,100*e-2200)}}],function(e,t){for(var n=0;n2&&void 0!==arguments[2]?arguments[2]:this.cloth;this.cylinder(e.pos,e.radius,.75*u.R/.5,t,n).position.setZ(-(.25*u.R)/.5/2)}},{key:"cylinder",value:function(e,t,n,r,i){var o=new s.Ho_(t,t,n,16),a=new s.eaF(o,i);return a.position.copy(e),a.geometry.applyMatrix4(new s.kn4().identity().makeRotationAxis(new s.Pq0(1,0,0),Math.PI/2)),r.add(a),a}},{key:"addCushions",value:function(e,t){var n=10*u.R/.5;this.plane(new s.Pq0(0,0,-u.R-n/2),2*l.P.X,2*l.P.Y,n,e,this.cloth);var r=1*u.R/.5,i=.75*u.R/.5,o=-(.25*u.R)/.5/2,a=l.P.X,h=l.P.Y,f=Math.abs(c.f.pockets.pocketNW.knuckleNE.pos.x-c.f.pockets.pocketN.knuckleNW.pos.x),p=Math.abs(c.f.pockets.pocketNW.knuckleSW.pos.y-c.f.pockets.pocketSW.knuckleNW.pos.y);t||(f=2*l.P.Y,p=2*l.P.Y+4*u.R),this.plane(new s.Pq0(a+r/2,0,o),r,p,i,e),this.plane(new s.Pq0(-a-r/2,0,o),r,p,i,e),this.plane(new s.Pq0(-a/2,h+r/2,o),f,r,i,e),this.plane(new s.Pq0(-a/2,-h-r/2,o),f,r,i,e),this.plane(new s.Pq0(a/2,h+r/2,o),f,r,i,e),this.plane(new s.Pq0(a/2,-h-r/2,o),f,r,i,e)}},{key:"plane",value:function(e,t,n,r,i){var o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:this.cushion,a=new s.iNn(t,n,r),l=new s.eaF(a,o);l.receiveShadow=!0,l.position.copy(e),i.add(l)}}],function(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:"",t=new n(e);return t.creatLocal(),t}}],e&&d(n.prototype,e),t&&d(n,t),n}()},"./src/view/cameratop.ts":(e,t,n)=>{n.d(t,{v:()=>a});var r=n("./node_modules/three/build/three.module.js"),i=n("./src/view/tablegeometry.ts"),s=n("./src/model/physics/constants.ts");function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var a=/*#__PURE__*/function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t)}return e=[{key:"viewPoint",value:function(e,n){var o=t.zoomFactor/(2*Math.tan(n*Math.PI/360));if(e>this.portrait){var a=e>t.aspectLimit?2.75*i.P.tableY:2.4*i.P.tableX/e;return new r.Pq0(0,-.01*s.R,o*a)}var l=e>1/t.aspectLimit?4.9*i.P.tableY:1.35*i.P.tableX/e;return new r.Pq0(-.01*s.R,0,o*l)}}],function(e,t){for(var n=0;n{n.d(t,{s:()=>f});var r=n("./src/view/tablegeometry.ts"),i=n("./src/utils/utils.ts"),s=n("./src/events/aimevent.ts"),o=n("./src/model/ball.ts"),a=n("./src/model/physics/physics.ts"),l=n("./src/view/cuemesh.ts"),c=n("./node_modules/three/build/three.module.js"),u=n("./src/model/physics/constants.ts");function h(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var f=/*#__PURE__*/function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),h(this,"mesh",void 0),h(this,"helperMesh",void 0),h(this,"placerMesh",void 0),h(this,"offCenterLimit",.3),h(this,"maxPower",150*u.R),h(this,"t",0),h(this,"aimInputs",void 0),h(this,"aim",new s.w),h(this,"length",1*r.P.tableX),this.mesh=l.l.createCue(.05*u.R/.5,.15*u.R/.5,this.length),this.helperMesh=l.l.createHelper(),this.placerMesh=l.l.createPlacer()}return e=[{key:"rotateAim",value:function(e,t){this.aim.angle=this.aim.angle+e,this.mesh.rotation.z=this.aim.angle,this.helperMesh.rotation.z=this.aim.angle,this.aimInputs.showOverlap(),this.avoidCueTouchingOtherBall(t)}},{key:"adjustPower",value:function(e){this.aim.power=Math.min(this.maxPower,this.aim.power+e),this.updateAimInput()}},{key:"setPower",value:function(e){this.aim.power=e*this.maxPower}},{key:"hit",value:function(e){var t=this.aim;this.t=0,e.state=o.U.Sliding,e.vel.copy((0,i.Dz)(t.angle).multiplyScalar(t.power)),e.rvel.copy((0,a.t6)(t.offset,e.vel))}},{key:"aimAtNext",value:function(e,t){if(t){var n=(0,i.xb)(t.pos.clone().sub(e.pos));this.aim.angle=Math.atan2(n.y,n.x)}}},{key:"adjustSpin",value:function(e,t){var n=this.aim.offset.clone().clone().add(e);this.setSpin(n,t)}},{key:"setSpin",value:function(e,t){e.length()>this.offCenterLimit&&e.normalize().multiplyScalar(this.offCenterLimit),this.aim.offset.copy(e),this.avoidCueTouchingOtherBall(t),this.updateAimInput()}},{key:"avoidCueTouchingOtherBall",value:function(e){for(var t=0;t++<20&&this.intersectsAnything(e);)this.aim.offset.y+=.1,this.aim.offset.length()>this.offCenterLimit&&this.aim.offset.normalize().multiplyScalar(this.offCenterLimit);t>1&&this.updateAimInput()}},{key:"updateAimInput",value:function(){var e,t,n;null===(e=this.aimInputs)||void 0===e||e.updateVisualState(this.aim.offset.x,this.aim.offset.y),null===(t=this.aimInputs)||void 0===t||t.updatePowerSlider(this.aim.power/this.maxPower),null===(n=this.aimInputs)||void 0===n||n.showOverlap()}},{key:"moveTo",value:function(e){this.aim.pos.copy(e),this.mesh.rotation.z=this.aim.angle,this.helperMesh.rotation.z=this.aim.angle;var t=this.spinOffset(),n=(Math.sin(this.t+Math.PI/2)-1)*2*u.R*(this.aim.power/this.maxPower),r=(0,i.Dz)(this.aim.angle).clone().multiplyScalar(n);this.mesh.position.copy(e.clone().add(t).add(r)),this.helperMesh.position.copy(e),this.placerMesh.position.copy(e),this.placerMesh.rotation.z=this.t}},{key:"update",value:function(e){this.t+=e,this.moveTo(this.aim.pos)}},{key:"placeBallMode",value:function(){this.mesh.visible=!1,this.placerMesh.visible=!0,this.aim.angle=0}},{key:"aimMode",value:function(){this.mesh.visible=!0,this.placerMesh.visible=!1}},{key:"spinOffset",value:function(){return(0,i.KM)((0,i.Dz)(this.aim.angle)).multiplyScalar(2*this.aim.offset.x*u.R).setZ(2*this.aim.offset.y*u.R)}},{key:"intersectsAnything",value:function(e){var t=this.spinOffset(),n=e.cueball.pos.clone().add(t),r=(0,i.xb)((0,i.Dz)(this.aim.angle+Math.PI).setZ(.1)),s=new c.tBo(n,r),o=e.balls.map(function(e){return e.ballmesh.mesh});return e.mesh&&o.push(e.mesh),s.intersectObjects(o,!0).length>0}},{key:"showHelper",value:function(e){this.helperMesh.visible=e}},{key:"toggleHelper",value:function(){this.showHelper(!this.helperMesh.visible)}}],function(e,t){for(var n=0;n{n.d(t,{l:()=>a});var r=n("./src/model/physics/constants.ts"),i=n("./src/utils/utils.ts"),s=n("./node_modules/three/build/three.module.js");function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var a=/*#__PURE__*/function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t)}return e=[{key:"indicateValid",value:function(e){t.placermaterial.color.setHex(e?0xccffcc:0xff0000)}},{key:"createHelper",value:function(){var e=new s.Ho_(r.R,r.R,30*r.R/.5,12,1,!0),t=new s.eaF(e,this.helpermaterial);return t.geometry.applyMatrix4(new s.kn4().identity().makeRotationAxis(i.up,-Math.PI/2)).applyMatrix4(new s.kn4().identity().makeTranslation(15*r.R/.5,0,-(.01*r.R)/.5)),t.visible=!1,t.renderOrder=-1,t.material.depthTest=!1,t}},{key:"createPlacer",value:function(){var e=new s.Ho_(.01*r.R/.5,r.R,r.R,4),n=new s.eaF(e,t.placermaterial);return n.geometry.applyMatrix4(new s.kn4().identity().makeRotationAxis(new s.Pq0(1,0,0),-Math.PI/2)).applyMatrix4(new s.kn4().identity().makeTranslation(0,0,.7*r.R/.5)),n.visible=!1,n}},{key:"createCue",value:function(e,n,o){var a=new s.Ho_(e,n,o,11),l=new s.eaF(a,t.material);return l.castShadow=!1,l.geometry.applyMatrix4(new s.kn4().identity().makeRotationAxis(new s.Pq0(1,0,0),-.17)).applyMatrix4(new s.kn4().identity().makeRotationAxis(i.up,-Math.PI/2)).applyMatrix4(new s.kn4().identity().makeTranslation(-o/2-r.R,0,o/2*.16918234906699603+.25*r.R)),l}}],function(e,t){for(var n=0;n{n.d(t,{f:()=>c});var r=n("./node_modules/three/build/three.module.js"),i=n("./src/model/physics/knuckle.ts"),s=n("./src/model/physics/pocket.ts"),o=n("./src/view/tablegeometry.ts"),a=n("./src/model/physics/constants.ts");function l(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var c=/*#__PURE__*/function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t)}return e=[{key:"scaleToRadius",value:function(e){t.PX=o.P.tableX+1.6*e,t.PY=o.P.tableY+1.6*e,t.knuckleInset=1.6*e/.5,t.knuckleRadius=.31*e/.5,t.middleKnuckleInset=1.385*e/.5,t.middleKnuckleRadius=.2*e/.5,t.cornerRadius=1.1*e/.5,t.middleRadius=.9*e/.5,t.pocketLayout(e),t.enumerateCenters(),t.enumerateKnuckles()}},{key:"enumerateKnuckles",value:function(){t.knuckles=[t.pockets.pocketNW.knuckleNE,t.pockets.pocketNW.knuckleSW,t.pockets.pocketN.knuckleNW,t.pockets.pocketN.knuckleNE,t.pockets.pocketS.knuckleSW,t.pockets.pocketS.knuckleSE,t.pockets.pocketNE.knuckleNW,t.pockets.pocketNE.knuckleSE,t.pockets.pocketSE.knuckleNE,t.pockets.pocketSE.knuckleSW,t.pockets.pocketSW.knuckleSE,t.pockets.pocketSW.knuckleNW]}},{key:"enumerateCenters",value:function(){t.pocketCenters=[t.pockets.pocketNW.pocket,t.pockets.pocketSW.pocket,t.pockets.pocketN.pocket,t.pockets.pocketS.pocket,t.pockets.pocketNE.pocket,t.pockets.pocketSE.pocket]}},{key:"pocketLayout",value:function(e){t.pockets={pocketNW:{pocket:new s.Z(new r.Pq0(-t.PX,t.PY,0),t.cornerRadius),knuckleNE:new i.O(new r.Pq0(-o.P.X+t.knuckleInset,o.P.Y+t.knuckleRadius,0),t.knuckleRadius),knuckleSW:new i.O(new r.Pq0(-o.P.X-t.knuckleRadius,o.P.Y-t.knuckleInset,0),t.knuckleRadius)},pocketN:{pocket:new s.Z(new r.Pq0(0,t.PY+.7*e/.5,0),t.middleRadius),knuckleNE:new i.O(new r.Pq0(t.middleKnuckleInset,o.P.Y+t.middleKnuckleRadius,0),t.middleKnuckleRadius),knuckleNW:new i.O(new r.Pq0(-t.middleKnuckleInset,o.P.Y+t.middleKnuckleRadius,0),t.middleKnuckleRadius)},pocketS:{pocket:new s.Z(new r.Pq0(0,-t.PY-.7*e/.5,0),t.middleRadius),knuckleSE:new i.O(new r.Pq0(t.middleKnuckleInset,-o.P.Y-t.middleKnuckleRadius,0),t.middleKnuckleRadius),knuckleSW:new i.O(new r.Pq0(-t.middleKnuckleInset,-o.P.Y-t.middleKnuckleRadius,0),t.middleKnuckleRadius)},pocketNE:{pocket:new s.Z(new r.Pq0(t.PX,t.PY,0),t.cornerRadius),knuckleNW:new i.O(new r.Pq0(o.P.X-t.knuckleInset,o.P.Y+t.knuckleRadius,0),t.knuckleRadius),knuckleSE:new i.O(new r.Pq0(o.P.X+t.knuckleRadius,o.P.Y-t.knuckleInset,0),t.knuckleRadius)},pocketSE:{pocket:new s.Z(new r.Pq0(t.PX,-t.PY,0),t.cornerRadius),knuckleNE:new i.O(new r.Pq0(o.P.X+t.knuckleRadius,-o.P.Y+t.knuckleInset,0),t.knuckleRadius),knuckleSW:new i.O(new r.Pq0(o.P.X-t.knuckleInset,-o.P.Y-t.knuckleRadius,0),t.knuckleRadius)},pocketSW:{pocket:new s.Z(new r.Pq0(-t.PX,-t.PY,0),t.cornerRadius),knuckleSE:new i.O(new r.Pq0(-o.P.X+t.knuckleInset,-o.P.Y-t.knuckleRadius,0),t.knuckleRadius),knuckleNW:new i.O(new r.Pq0(-o.P.X-t.knuckleRadius,-o.P.Y+t.knuckleInset,0),t.knuckleRadius)}}}}],function(e,t){for(var n=0;n{n.d(t,{r:()=>s});var r=n("./src/model/physics/constants.ts");function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var s=/*#__PURE__*/function(){var e;function t(e){var n,s;!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),i(this,"style",void 0),i(this,"notify",void 0),this.notify=null!=e?e:function(){},this.style=null!==(s=null===(n=document.getElementById("constants"))||void 0===n?void 0:n.style)&&void 0!==s?s:{},this.initialiseSlider("R",r.R,r.jG),this.initialiseSlider("m",r.m,r.Qg),this.initialiseSlider("e",r.e,r.cM),this.initialiseSlider("mu",r.mu,r.xO),this.initialiseSlider("muS",r.gf,r.Ys),this.initialiseSlider("muC",r.gT,r.kM),this.initialiseSlider("rho",r.kL,r.Wv)}return e=[{key:"toggleVisibility",value:function(){this.style.visibility="visible"===this.style.visibility?"hidden":"visible"}},{key:"getInputElement",value:function(e){var t;return null!==(t=document.getElementById(e))&&void 0!==t?t:{}}},{key:"initialiseSlider",value:function(e,t,n){var r=this,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,s=this.getInputElement(e);s.step="0.001",s.min="0.01",s.max="".concat(i),s.value=t,this.showValue(e,t),s.oninput=function(t){var i=parseFloat(t.target.value);n(i),r.showValue(e,i),r.notify()}}},{key:"showValue",value:function(e,t){var n=document.querySelector("label[for=".concat(e,"]"));n&&(n.innerHTML="".concat(e,"=").concat(t))}}],function(e,t){for(var n=0;n{n.d(t,{P:()=>s});var r=n("./src/model/physics/constants.ts");function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var s=/*#__PURE__*/function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t)}return e=[{key:"scaleToRadius",value:function(e){t.tableX=43*e,t.tableY=21*e,t.X=t.tableX+e,t.Y=t.tableY+e}}],function(e,t){for(var n=0;n{e(e.s="./src/diagrams.ts")}]); \ No newline at end of file diff --git a/dist/diagrams/forreadme.md b/dist/diagrams/forreadme.md index 3ac75ec1..36865cc3 100644 --- a/dist/diagrams/forreadme.md +++ b/dist/diagrams/forreadme.md @@ -1,40 +1,32 @@ -Slip velocity at cushion contact point I +Cushion bounce -$$ -ẋ_I = \dot{v_x} + \dot{\omega_y} R \sin \theta - \dot{\omega_z} R \cos \theta -$$ +This is based on [Mathaven paper](https://billiards.colostate.edu/physics_articles/Mathavan_IMechE_2010.pdf). Many of the [figures](https://tailuge.github.io/billiards/dist/diagrams/mathaven.html) from the paper are recreated to confirm correctness. -$$ -ẏ'_I = -\dot{v_y} \sin \theta + \dot{\omega_x} R -$$ +Slip velocity at cushion contact point I $$ -\phi = \arctan\left(\frac{ẏ'_I}{ẋ_I}\right) +ẋ_I = \dot{v_x} + \dot{\omega_y} R \sin \theta - \dot{\omega_z} R \cos \theta, +ẏ'_I = -\dot{v_y} \sin \theta + \dot{\omega_x} R $$ $$ +\phi = \arctan\left(\frac{ẏ'_I}{ẋ_I}\right), s = \sqrt{(ẋ_I)^2 + (ẏ'_I)^2} $$ Slip velocity at table contact point C $$ -ẋ_C = \dot{v_x} - \dot{\omega_y} R -$$ - -$$ +ẋ_C = \dot{v_x} - \dot{\omega_y} R, ẏ_C = \dot{v_y} + \dot{\omega_x} R $$ $$ -\phi' = \arctan\left(\frac{ẏ'_I}{ẋ_I}\right) -$$ - -$$ +\phi' = \arctan\left(\frac{ẏ'_I}{ẋ_I}\right), s' = \sqrt{(ẋ_C)^2 + (ẏ_C)^2} $$ -Numerical updates to the centroid velocity of the ball during compression and resititution phases. +Numerical solutions for the centroid velocity of the ball during compression and resititution phases. $$ (\dot{v_x})_{n+1} - (\dot{v_x})_n = - \frac{1}{M} \left[\mu_w \cos(\phi) + \mu_s \cos(\phi') \cdot (\sin \theta + \mu_w \sin(\phi) \cos \theta)\right] \Delta P_I @@ -44,7 +36,7 @@ $$ (\dot{v_y})_{n+1} - (\dot{v_y})_n = - \frac{1}{M} \left[ \cos \theta - \mu_w \sin \theta \sin \phi + \mu_s \sin \phi' \cdot \left( \sin \theta + \mu_w \sin \phi \cos \theta \right) \right] \Delta P_I $$ -Updates for angular velocity of ball +Numerical solutions for angular velocity of ball $$ (\dot{\omega_x})_{n+1}−(\dot{\omega_x})_n = -\frac{5}{2MR}[\mu_w \sin(\phi) + \mu_s \sin(\phi') \times (\sin(\theta) + \mu_w \sin(\phi)\cos(\theta))]\Delta P_I @@ -60,9 +52,9 @@ $$ (\dot{\omega_z})_{n+1}−(\dot{\omega_z})_n = \frac{5}{2MR}(\mu_w \cos(\phi)\cos(\theta))\Delta P_I $$ -$`\theta`$ is a constant of the angle of cushion contact above ball centre with $`\sin(\theta) = 2/5`$ +$`\theta`$ is a constant of the angle of cushion contact above ball centre with $`\sin(\theta) = 2/5`$. $`μ_s`$ is the coefficient of sliding friction between the ball and table surface. $`μ_w`$ is the coefficient of sliding friction between the ball and the cushion. -Work done by the normal force at contact point $I$ along the $Z'$-axis +Work done by the normal force at contact point $I$ along the $Z'$-axis which is aligned from the ball centre to I $$ W_{Z'}^I(P_I^{(n+1)}) = W_{Z'}^I(P_I^{(n)}) + \frac{\Delta P_I}{2} \left( z'_I(P_I^{(n+1)}) + z'_I(P_I^{(n)}) \right) diff --git a/dist/index.js b/dist/index.js index 695caba0..d607a145 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1 +1 @@ -"use strict";(self.webpackChunkbilliards=self.webpackChunkbilliards||[]).push([[57],{"./src/container/container.ts":(e,t,n)=>{n.d(t,{m:()=>Z});var r=n("./src/events/stationaryevent.ts"),i=n("./node_modules/three/build/three.module.js"),s=n("./src/utils/utils.ts"),o=n("./src/view/cameratop.ts"),a=n("./src/model/physics/constants.ts");function l(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var c=/*#__PURE__*/function(){var e;function t(e){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),l(this,"camera",void 0),l(this,"mode",this.topView),l(this,"mainMode",this.aimView),l(this,"height",8*a.R),l(this,"elapsed",void 0),this.camera=new i.ubm(45,e,a.R,1e3*a.R)}return e=[{key:"update",value:function(e,t){this.elapsed=e,this.mode(t)}},{key:"topView",value:function(e){this.camera.fov=o.v.fov,this.camera.position.lerp(o.v.viewPoint(this.camera.aspect,this.camera.fov),.9),this.camera.up=s.up,this.camera.lookAt(s.v_)}},{key:"aimView",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.08,n=this.height,r=this.camera.aspect<.8;if(this.camera.fov=r?60:40,n<10*a.R){var i=100*(10*a.R-n);this.camera.fov-=i*(r?3:1)}this.camera.position.lerp(e.pos.clone().addScaledVector((0,s.Dz)(e.angle),-(18*a.R)),t),this.camera.position.z=n,this.camera.up=s.up,this.camera.lookAt(e.pos.clone().addScaledVector(s.up,n/2))}},{key:"adjustHeight",value:function(e){e=this.height<10*a.R?e/8:e,this.height=i.cj9.clamp(this.height+e,6*a.R,120*a.R),this.height>110*a.R&&this.suggestMode(this.topView),this.height<105*a.R&&this.suggestMode(this.aimView)}},{key:"suggestMode",value:function(e){this.mainMode===this.aimView&&(this.mode=e)}},{key:"forceMode",value:function(e){this.mode=e,this.mainMode=e}},{key:"forceMove",value:function(e){this.mode===this.aimView&&this.aimView(e,1)}},{key:"toggleMode",value:function(){this.mode===this.topView?this.mode=this.aimView:this.mode=this.topView,this.mainMode=this.mode}}],function(e,t){for(var n=0;n0&&(null===(t=this.cuePowerElement)||void 0===t?void 0:t.value)&&(this.cuePowerElement.value=e)}}],function(e,t){for(var n=0;nthis.sentTime+this.period||e.type!==L.B.AIM){this.flush(),this.apply(e),this.sentTime=performance.now();return}this.pending=e}}],function(e,t){for(var n=0;n0&&"RERACK"===this.shots[e].type&&e--,e}},{key:"lastShot",value:function(){var e=this.last();return this.state(this.states[e],[this.shots[e]])}},{key:"currentBreak",value:function(){if(void 0!==this.breakStart)return this.state(this.states[this.breakStart],this.shots.slice(this.breakStart),this.breakStartTime,this.container.rules.previousBreak)}},{key:"state",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];return{init:e,shots:t,start:n,now:Date.now(),score:r,wholeGame:i}}},{key:"updateBreak",value:function(e){var t=this.container.rules.isPartOfBreak(e),n=this.container.rules.isEndOfGame(e),r=D.P.potCount(e);if(t||this.breakLink(n),this.lastShotLink(t||n,r,D.P.pots(e)),n&&this.breakLink(n),!t){this.breakStart=void 0;return}void 0===this.breakStart&&(this.breakStart=this.last(),this.breakStartTime=Date.now())}},{key:"lastShotLink",value:function(e,t,n){var r="#000000";n.length>0&&n.forEach(function(e){r="#"+e.ballmesh.color.getHexString()});var i="⚈".repeat(t>1?t-1:0)+(e?"⚈":"⚆"),s=JSON.stringify(this.lastShot());this.generateLink(i,s,r)}},{key:"breakLink",value:function(e){var t=this.currentBreak();if(t&&(e||t.shots.pop(),1!==t.shots.length)){var n=0===this.container.rules.currentBreak?this.container.rules.previousBreak:this.container.rules.currentBreak;t.score=n;var r=JSON.stringify(t),i=z.A.crush(r);this.generateLink("break(".concat(n,")"),i,"black"),n>=4&&this.generateHiScoreLink(i)}}},{key:"wholeGameLink",value:function(){var e=this.wholeGame(),t="frame(".concat(this.shotCount(e.shots)," shots)"),n=JSON.stringify(e),r=z.A.crush(n);this.generateLink(t,r,"black")}},{key:"shotCount",value:function(e){return e.filter(function(e){return"RERACK"!==e.type}).length}},{key:"generateLink",value:function(e,t,n){var r="".concat(this.replayUrl).concat(this.fullyEncodeURI(t)),i='').concat(e,"");this.container.eventQueue.push(new N.b(null,"".concat(i)))}},{key:"generateHiScoreLink",value:function(e){var t="".concat(this.hiScoreUrl,"?ruletype=").concat(this.container.rules.rulename,"&state=").concat(this.fullyEncodeURI(e)),n='').concat("hi score 🏆","");this.container.eventQueue.push(new N.b(null,"".concat(n)))}},{key:"fullyEncodeURI",value:function(e){return encodeURIComponent(e).replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/\!/g,"%21").replace(/\*/g,"%2A")}}],function(e,t){for(var n=0;n').concat(e,"")));r.push(new N.b(null,o))})},this.redo.onclick=function(e){var r=new X.W(t.init,t.shots);r.retry=!0,n.interuptEventQueue(r)},this.replay.onclick=function(e){n.interuptEventQueue(t)}}}},{key:"interuptEventQueue",value:function(e){this.container.table.halt();var t=this.container.eventQueue;t.length=0,t.push(new r.T),t.push(e)}},{key:"getElement",value:function(e){return document.getElementById(e)}}],function(e,t){for(var n=0;n0?this.element.innerHTML="Break
"+e:this.element.innerHTML="")}},{key:"getElement",value:function(e){return document.getElementById(e)}}],function(e,t){for(var n=0;n0;){this.lastEventTime=this.last;var t=this.inputQueue.shift();t&&this.updateController(this.controller.handleInput(t))}if(this.table.allStationary()){var n=this.eventQueue.shift();n&&(this.lastEventTime=performance.now(),this.updateController(n.applyToController(this.controller)))}}},{key:"animate",value:function(e){var t=this;this.advance((e-this.last)/1e3),this.last=e,this.processEvents(),(e{n.d(t,{m:()=>u});var r=n("./src/controller/controller.ts"),i=n("./src/controller/controllerbase.ts"),s=n("./src/controller/playshot.ts"),o=n("./src/controller/replay.ts");function a(e){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function l(e,t){return(l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(c=function(){return!!e})()}var u=/*#__PURE__*/function(e){var t;function n(e){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,n),r=n,i=[e],r=a(r);var t,r,i,s,o=(s=(t=c()?Reflect.construct(r,i||[],a(this).constructor):r.apply(this,i))&&("object"==(t&&"undefined"!=typeof Symbol&&t.constructor===Symbol?"symbol":typeof t)||"function"==typeof t)?t:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this)).container.table;return o.cue.aimMode(),o.cue.showHelper(!0),o.cueball=s.container.rules.cueball,o.cue.moveTo(o.cueball.pos),s.container.view.camera.suggestMode(s.container.view.camera.aimView),o.cue.aimInputs.showOverlap(),s}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&l(e,t)}(n,e),t=[{key:"handleInput",value:function(e){switch(e.key){case"Space":this.container.table.cue.adjustPower(e.t*this.scale*.7);break;case"SpaceUp":return this.playShot();default:if(!this.commonKeyHandler(e))return this}return this.container.sendEvent(this.container.table.cue.aim),this}},{key:"handleBreak",value:function(e){return new o.e(this.container,e.init,e.shots,e.retry)}},{key:"playShot",value:function(){var e=new r.Qe(this.container.table.serialise());return this.container.sendEvent(e),this.container.recorder.record(e),new s.H(this.container)}}],function(e,t){for(var n=0;n{n.d(t,{Qe:()=>r.Q,pd:()=>i.p,xI:()=>s}),n("./src/events/beginevent.ts"),n("./src/events/aimevent.ts");var r=n("./src/events/hitevent.ts"),i=n("./src/events/input.ts");n("./src/events/abortevent.ts"),n("./src/events/stationaryevent.ts");var s=/*#__PURE__*/function(){var e;function t(e){var n,r;!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),r=void 0,(n="container")in this?Object.defineProperty(this,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):this[n]=r,this.container=e}return e=[{key:"handleInput",value:function(e){return this}},{key:"handleBegin",value:function(e){return this}},{key:"handleBreak",value:function(e){return this}},{key:"handleStartAim",value:function(e){return this}},{key:"handleAim",value:function(e){return this}},{key:"handleHit",value:function(e){return this}},{key:"handleAbort",value:function(e){return this}},{key:"handleWatch",value:function(e){return this}},{key:"handlePlaceBall",value:function(e){return this}},{key:"handleStationary",value:function(e){return this}},{key:"handleChat",value:function(e){return this}},{key:"handleRejoin",value:function(e){return this}},{key:"onFirst",value:function(){}}],function(e,t){for(var n=0;n{n.d(t,{y:()=>f});var r=n("./src/controller/controller.ts"),i=n("./src/controller/end.ts"),s=n("./src/utils/gltf.ts"),o=n("./src/model/outcome.ts"),a=n("./node_modules/three/build/three.module.js");function l(e){return(l=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function u(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function h(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(h=function(){return!!e})()}var f=/*#__PURE__*/function(e){var t;function n(){var e,t,r,i,s;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,n),t=n,r=arguments,t=l(t),(i="scale")in(e=(s=h()?Reflect.construct(t,r||[],l(this).constructor):t.apply(this,r))&&("object"===u(s)||"function"==typeof s)?s:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this))?Object.defineProperty(e,i,{value:.001,enumerable:!0,configurable:!0,writable:!0}):e[i]=.001,e}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c(e,t)}(n,e),t=[{key:"handleAbort",value:function(e){return new i.o(this.container)}},{key:"handleChat",value:function(e){var t=e.sender?"".concat(e.sender,":"):"",n="".concat(t," ").concat(e.message);return this.container.chat.showMessage(n),this}},{key:"hit",value:function(){this.container.table.outcome=[o.P.hit(this.container.table.cueball,this.container.table.cue.aim.power)],this.container.table.hit(),this.container.view.camera.suggestMode(this.container.view.camera.aimView),this.container.table.cue.showHelper(!1)}},{key:"commonKeyHandler",value:function(e){var t=this.container.table.cue,n=e.t*this.scale;switch(e.key){case"ArrowLeft":return t.rotateAim(-n,this.container.table),!0;case"ArrowRight":return t.rotateAim(n,this.container.table),!0;case"ArrowDown":return t.adjustSpin(new a.Pq0(0,-n),this.container.table),!0;case"ArrowUp":return t.adjustSpin(new a.Pq0(0,n),this.container.table),!0;case"ShiftArrowLeft":return t.adjustSpin(new a.Pq0(n,0),this.container.table),!0;case"ShiftArrowRight":return t.adjustSpin(new a.Pq0(-n,0),this.container.table),!0;case"KeyPUp":return(0,s.KP)(this.container.view.scene),!0;case"KeyHUp":return t.toggleHelper(),!0;case"movementXUp":return t.rotateAim(2*n,this.container.table),!0;case"movementYUp":case"NumpadSubtract":return this.container.view.camera.adjustHeight(8*n),!0;case"NumpadAdd":return this.container.view.camera.adjustHeight(-(8*n)),!0;case"KeyOUp":return this.container.view.camera.toggleMode(),!0;case"KeyDUp":return this.togglePanel(),!0;case"KeyFUp":return this.toggleFullscreen(),!0;default:return!1}}},{key:"togglePanel",value:function(){this.container.sliders.toggleVisibility(),this.container.table.showSpin(!0),this.container.table.showTraces(!0),("undefined"==typeof process?"undefined":u(process))!=="object"&&console.log(this.container.table.serialise())}},{key:"toggleFullscreen",value:function(){document.fullscreenElement?document.exitFullscreen&&document.exitFullscreen():document.documentElement.requestFullscreen()}}],function(e,t){for(var n=0;n{function r(e){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function i(e,t){return(i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function s(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(s=function(){return!!e})()}n.d(t,{o:()=>o});var o=/*#__PURE__*/function(e){var t;function n(){var e,t,i;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,n),e=n,t=arguments,e=r(e),(i=s()?Reflect.construct(e,t||[],r(this).constructor):e.apply(this,t))&&("object"==(i&&"undefined"!=typeof Symbol&&i.constructor===Symbol?"symbol":typeof i)||"function"==typeof i)?i:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this)}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&i(e,t)}(n,e),t=[{key:"handleChat",value:function(e){var t=e.sender?"".concat(e.sender,":"):"",n="".concat(t," ").concat(e.message);return this.container.chat.showMessage(n),this}}],function(e,t){for(var n=0;n{n.d(t,{x:()=>p});var r=n("./src/controller/controllerbase.ts"),i=n("./src/controller/controller.ts"),s=n("./src/controller/aim.ts"),o=n("./src/events/breakevent.ts"),a=n("./src/model/physics/constants.ts"),l=n("./node_modules/three/build/three.module.js"),c=n("./src/view/cuemesh.ts");function u(e){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function h(e,t){return(h=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function f(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(f=function(){return!!e})()}var p=/*#__PURE__*/function(e){var t;function n(e){var t,r,i,s,o,l,c;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,n),r=n,i=[e],r=u(r),s=t=(c=f()?Reflect.construct(r,i||[],u(this).constructor):r.apply(this,i))&&("object"==(c&&"undefined"!=typeof Symbol&&c.constructor===Symbol?"symbol":typeof c)||"function"==typeof c)?c:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this),o="placescale",l=.02*a.R,o in s?Object.defineProperty(s,o,{value:l,enumerable:!0,configurable:!0,writable:!0}):s[o]=l,t.container.table.cue.moveTo(t.container.table.cueball.pos),t.container.table.cue.aim.power=0,t.container.view.camera.forceMode(t.container.view.camera.aimView),t}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&h(e,t)}(n,e),t=[{key:"onFirst",value:function(){var e=this.container.table.cueball;this.container.rules.allowsPlaceBall()&&e.pos.copy(this.container.rules.placeBall()),e.setStationary(),e.updateMesh(0),this.container.table.cue.placeBallMode(),this.container.table.cue.showHelper(!1),this.container.table.cue.moveTo(this.container.table.cueball.pos),this.container.table.cue.aimInputs.setButtonText("Place\nBall"),this.container.rules.allowsPlaceBall()||this.container.inputQueue.push(new i.pd(1,"SpaceUp"))}},{key:"handleInput",value:function(e){var t=this.container.table.cueball.pos;switch(e.key){case"ArrowLeft":case"KeyI":this.moveTo(0,e.t*this.placescale);break;case"ArrowRight":case"KeyK":this.moveTo(0,-e.t*this.placescale);break;case"movementXUp":this.moveTo(0,-e.t*this.placescale*2);break;case"movementYUp":this.moveTo(-e.t*this.placescale*2,0);break;case"KeyJ":this.moveTo(-e.t*this.placescale,0);break;case"KeyL":this.moveTo(e.t*this.placescale,0);break;case"SpaceUp":return this.placed();default:this.commonKeyHandler(e)}return this.container.table.cue.moveTo(t),this.container.view.camera.forceMove(this.container.table.cue.aim),this.container.sendEvent(this.container.table.cue.aim),this}},{key:"moveTo",value:function(e,t){var n=new l.Pq0(e,t),r=this.container.table.cueball.pos.add(n);r.copy(this.container.rules.placeBall(r)),c.l.indicateValid(!this.container.table.overlapsAny(r))}},{key:"placed",value:function(){return this.container.table.overlapsAny(this.container.table.cueball.pos)?this:(this.container.table.cue.aimInputs.setButtonText("Hit"),this.container.sound.playNotify(),this.container.sendEvent(new o.W(this.container.table.shortSerialise())),new s.m(this.container))}}],function(e,t){for(var n=0;n{function r(e){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function i(e,t){return(i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function s(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(s=function(){return!!e})()}n.d(t,{H:()=>o});var o=/*#__PURE__*/function(e){var t;function n(e){var t,i,o,a;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,n),i=n,o=[e],i=r(i),(t=(a=s()?Reflect.construct(i,o||[],r(this).constructor):i.apply(this,o))&&("object"==(a&&"undefined"!=typeof Symbol&&a.constructor===Symbol?"symbol":typeof a)||"function"==typeof a)?a:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this)).hit(),t}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&i(e,t)}(n,e),t=[{key:"handleStationary",value:function(e){var t=this.container.table,n=t.outcome,r=this.container.rules.update(n);return this.container.recorder.updateBreak(n),t.cue.aimAtNext(t.cueball,this.container.rules.nextCandidateBall()),r}},{key:"handleInput",value:function(e){return this.commonKeyHandler(e),this}}],function(e,t){for(var n=0;n{n.d(t,{e:()=>m});var r=n("./src/events/hitevent.ts"),i=n("./src/controller/controllerbase.ts"),s=n("./src/events/aimevent.ts"),o=n("./src/events/breakevent.ts"),a=n("./src/controller/aim.ts"),l=n("./src/events/eventtype.ts"),c=n("./src/events/rerackevent.ts");function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n3&&void 0!==arguments[3]&&arguments[3],u=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1500;if(!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,n),s=n,a=[e],s=f(s),h(l=(i=v()?Reflect.construct(s,a||[],f(this).constructor):s.apply(this,a))&&("object"==(i&&"undefined"!=typeof Symbol&&i.constructor===Symbol?"symbol":typeof i)||"function"==typeof i)?i:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this),"delay",void 0),h(l,"shots",void 0),h(l,"firstShot",void 0),h(l,"timer",void 0),h(l,"init",void 0),l.init=t,l.shots=d(r),l.firstShot=l.shots[0],l.delay=u,l.container.table.showTraces(!0),l.container.table.updateFromShortSerialised(l.init),c){var p=new o.W(t,r);p.retry=!0,l.container.eventQueue.push(p)}else l.container.view.camera.forceMode(l.container.view.camera.topView),l.playNextShot(1.5*l.delay);return l}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&p(e,t)}(n,e),t=[{key:"playNextShot",value:function(e){var t=this,n=this.shots.shift();if((null==n?void 0:n.type)===l.B.RERACK){c.x.fromJson(n.ballinfo).applyToController(this),this.shots.length>0&&this.playNextShot(e);return}var i=s.w.fromJson(n);this.container.table.cueball=this.container.table.balls[i.i],console.log(this.container.table.cueball.pos.distanceTo(i.pos)),this.container.table.cueball.pos.copy(i.pos),this.container.table.cue.aim=i,this.container.table.cue.updateAimInput(),this.container.table.cue.t=1,clearTimeout(this.timer),this.timer=setTimeout(function(){t.container.eventQueue.push(new r.Q(t.container.table.cue.aim)),t.timer=void 0},e)}},{key:"handleHit",value:function(e){return this.hit(),this}},{key:"handleStationary",value:function(e){return this.shots.length>0&&void 0===this.timer&&this.playNextShot(this.delay),this}},{key:"handleInput",value:function(e){return this.commonKeyHandler(e),this}},{key:"handleBreak",value:function(e){return(this.container.table.updateFromShortSerialised(e.init),this.shots=d(e.shots),this.container.table.showSpin(!0),e.retry)?this.retry():(this.playNextShot(this.delay),this)}},{key:"retry",value:function(){clearTimeout(this.timer),this.timer=void 0,this.container.table.updateFromShortSerialised(this.init);var e=s.w.fromJson(this.firstShot);return this.container.table.cueball=this.container.table.balls[e.i],this.container.rules.cueball=this.container.table.cueball,this.container.table.cueball.pos.copy(e.pos),this.container.table.cue.aim=e,this.container.view.camera.forceMode(this.container.view.camera.aimView),new a.m(this.container)}}],function(e,t){for(var n=0;n{n.d(t,{V:()=>M});var r=n("./src/events/watchevent.ts"),i=n("./src/utils/rack.ts"),s=n("./node_modules/three/build/three.module.js"),o=n("./src/controller/aim.ts"),a=n("./src/controller/placeball.ts"),l=n("./src/controller/watchaim.ts"),c=n("./src/events/chatevent.ts"),u=n("./src/events/placeballevent.ts"),h=n("./src/model/outcome.ts"),f=n("./src/model/table.ts"),p=n("./src/utils/utils.ts"),d=n("./src/controller/end.ts"),v=n("./src/model/physics/constants.ts"),m=n("./src/utils/respot.ts"),y=n("./src/view/tablegeometry.ts"),b=n("./src/events/startaimevent.ts");function g(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var w=/*#__PURE__*/function(){var e;function t(e){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),g(this,"container",void 0),g(this,"cueball",void 0),g(this,"currentBreak",0),g(this,"previousBreak",0),g(this,"score",0),g(this,"rulename","nineball"),this.container=e}return e=[{key:"startTurn",value:function(){this.previousBreak=this.currentBreak,this.currentBreak=0}},{key:"nextCandidateBall",value:function(){return m.k.closest(this.container.table.cueball,this.container.table.balls)}},{key:"placeBall",value:function(e){if(e){var t=new s.Pq0(-y.P.X/2,y.P.tableY),n=new s.Pq0(-y.P.tableX,-y.P.tableY);return e.clamp(n,t)}return new s.Pq0(-(11*v.R)/.5,0,0)}},{key:"asset",value:function(){return"models/p8.min.gltf"}},{key:"tableGeometry",value:function(){y.P.hasPockets=!0}},{key:"table",value:function(){var e=new f.X(this.rack());return this.cueball=e.cueball,e}},{key:"rack",value:function(){return i.m.diamond()}},{key:"update",value:function(e){var t=this.container.table;if(h.P.isCueBallPotted(t.cueball,e))return(this.startTurn(),this.container.isSinglePlayer)?new a.x(this.container):(this.container.sendEvent(new u.z(p.v_,!0)),new l.r(this.container));if(h.P.isBallPottedNoFoul(t.cueball,e)){var n=h.P.potCount(e);return(this.currentBreak+=n,this.score+=n,this.container.sound.playSuccess(t.inPockets()),this.isEndOfGame(e))?(this.container.eventQueue.push(new c.b(null,"game over")),this.container.recorder.wholeGameLink(),new d.o(this.container)):(this.container.sendEvent(new r.Q(t.serialise())),new o.m(this.container))}return(this.container.sendEvent(new b.M),this.container.isSinglePlayer)?(this.container.sendEvent(new r.Q(t.serialise())),this.startTurn(),new o.m(this.container)):new l.r(this.container)}},{key:"isPartOfBreak",value:function(e){return h.P.isBallPottedNoFoul(this.container.table.cueball,e)}},{key:"isEndOfGame",value:function(e){var t=this.container.table.balls.filter(function(e){return e.onTable()});return 1===t.length&&t[0]===this.cueball}},{key:"otherPlayersCueBall",value:function(){return this.cueball}},{key:"secondToPlay",value:function(){}},{key:"allowsPlaceBall",value:function(){return!0}}],function(e,t){for(var n=0;n{n.d(t,{c:()=>k});var r=n("./node_modules/three/build/three.module.js"),i=n("./src/events/watchevent.ts"),s=n("./src/model/outcome.ts"),o=n("./src/utils/rack.ts"),a=n("./src/utils/respot.ts"),l=n("./src/controller/aim.ts"),c=n("./src/controller/watchaim.ts"),u=n("./src/events/chatevent.ts"),h=n("./src/controller/end.ts"),f=n("./src/model/table.ts"),p=n("./src/view/tablegeometry.ts"),d=n("./src/controller/placeball.ts"),v=n("./src/events/placeballevent.ts"),m=n("./src/utils/utils.ts"),y=/*#__PURE__*/function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t)}return e=[{key:"shotInfo",value:function(e,n,r){var i=s.P.firstCollision(n);return{pots:s.P.potCount(n),firstCollision:i,legalFirstCollision:t.isLegalFirstCollision(e,r,i),whitePotted:s.P.isCueBallPotted(e.cueball,n)}}},{key:"isLegalFirstCollision",value:function(e,n,r){if(!r)return!1;var i=r.ballB.id;return n?i>=7:!(t.coloursOnTable(e).filter(function(e){return e.id0)}},{key:"respotAllPottedColours",value:function(e,t){return s.P.pots(t).filter(function(e){return e.id<7}).filter(function(e){return 0!==e.id}).map(function(t){return a.k.respot(t,e)})}},{key:"redsOnTable",value:function(e){return e.balls.slice(7).filter(function(e){return e.onTable()})}},{key:"coloursOnTable",value:function(e){return e.balls.slice(1,7).filter(function(e){return e.onTable()})}}],function(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,r=Array(t);n0,this.switchPlayer()}return this.targetIsRed?this.targetRedRule(e,t):this.targetColourRule(e,t)}},{key:"targetRedRule",value:function(e,t){return(console.log("applying target red rule"),t.legalFirstCollision&&s.P.onlyRedsPotted(e))?(this.currentBreak+=t.pots,this.targetIsRed=!1,this.previousPotRed=!0,this.container.hud.updateBreak(this.currentBreak),this.continueBreak()):(this.foulPoints=this.foulCalculation(e,t),this.respot(e),t.whitePotted)?this.whiteInHand():this.switchPlayer()}},{key:"targetColourRule",value:function(e,t){if(console.log("applying target colour rule"),t.whitePotted)return this.respot(e),this.whiteInHand();if(t.pots>1)return this.foulPoints=this.foulCalculation(e,t),this.respot(e),this.switchPlayer();if(s.P.pots(e)[0].id>6)return this.foulPoints=this.foulCalculation(e,t),this.switchPlayer();this.targetIsRed=y.redsOnTable(this.container.table).length>0;var n=s.P.pots(e)[0].id;return n!==t.firstCollision.ballB.id?this.foul(e,t):this.previousPotRed?(this.respot(e),this.currentBreak+=n+1,this.previousPotRed=!1,this.continueBreak()):y.coloursOnTable(this.container.table).filter(function(e){return e.id0?this.foul(e,t):(this.currentBreak+=n+1,this.previousPotRed=!1,this.continueBreak())}},{key:"foul",value:function(e,t){return this.foulPoints=this.foulCalculation(e,t),this.respot(e),this.switchPlayer()}},{key:"foulCalculation",value:function(e,t){var n,r,i,o,a=s.P.pots(e).map(function(e){return e.id}).filter(function(e){return e<7}),l=null!==(o=null===(i=t.firstCollision)||void 0===i?void 0:null===(r=i.ballB)||void 0===r?void 0:r.id)&&void 0!==o?o:0;return l>6&&(l=0),(n=Math).max.apply(n,[3,l].concat(function(e){if(Array.isArray(e))return g(e)}(a)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(a)||function(e,t){if(e){if("string"==typeof e)return g(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return g(e,void 0)}}(a)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()))+1}},{key:"tableGeometry",value:function(){p.P.hasPockets=!0}},{key:"table",value:function(){var e=new f.X(this.rack());return this.cueball=e.cueball,e}},{key:"otherPlayersCueBall",value:function(){return this.cueball}},{key:"secondToPlay",value:function(){}},{key:"isPartOfBreak",value:function(e){return this.currentBreak>0}},{key:"isEndOfGame",value:function(e){return s.P.isClearTable(this.container.table)&&this.currentBreak>0}},{key:"allowsPlaceBall",value:function(){return!0}},{key:"asset",value:function(){return t.tablemodel}},{key:"startTurn",value:function(){this.previousPotRed=!1,this.targetIsRed=y.redsOnTable(this.container.table).length>0,this.previousBreak=this.currentBreak,this.score+=this.currentBreak,this.currentBreak=0,this.container.hud.updateBreak(this.currentBreak)}},{key:"rack",value:function(){return o.m.snooker()}},{key:"nextCandidateBall",value:function(){var e=this.container.table,t=y.redsOnTable(e),n=y.coloursOnTable(e);return this.previousPotRed?a.k.closest(e.cueball,n):t.length>0?a.k.closest(e.cueball,t):n.length>0?n[0]:void 0}},{key:"placeBall",value:function(e){if(e){var t=new r.Pq0(o.m.baulk,0,0),n=o.m.sixth,i=e.distanceTo(t);if(e.x>=o.m.baulk&&(e.x=o.m.baulk),!(i>n))return e;var s=e.clone().sub(t).normalize();return t.add(s.multiplyScalar(n))}return new r.Pq0(o.m.baulk,-o.m.sixth/2.6,0)}},{key:"switchPlayer",value:function(){this.foulPoints>0&&console.log("foul, ".concat(this.foulPoints," to opponent")),console.log("end of break, switch player");var e=this.container.table;return(console.log(e.cue.aim),this.container.sendEvent(new b.M(this.foulPoints)),this.container.isSinglePlayer)?(this.container.sendEvent(new i.Q(e.serialise())),this.startTurn(),new l.m(this.container)):new c.r(this.container)}},{key:"continueBreak",value:function(){this.container.hud.updateBreak(this.currentBreak);var e=this.container.table;return(this.container.sound.playSuccess(e.inPockets()),s.P.isClearTable(e))?(this.container.eventQueue.push(new u.b(null,"game over")),this.container.recorder.wholeGameLink(),new h.o(this.container)):(this.container.sendEvent(new i.Q(e.serialise())),new l.m(this.container))}},{key:"whiteInHand",value:function(){return(this.foulPoints>0&&console.log("foul, ".concat(this.foulPoints," to opponent")),this.startTurn(),this.container.isSinglePlayer)?new d.x(this.container):(this.container.sendEvent(new v.z(m.v_,!0)),new c.r(this.container))}},{key:"update",value:function(e){return this.snookerrule(e)}},{key:"respot",value:function(e){var t=y.respotAllPottedColours(this.container.table,e);if(t.length>0){var n={balls:t.map(function(e){return e.serialise()}),rerack:!0},r=new i.Q(n);this.container.sendEvent(r),this.container.recorder.record(r)}}}],function(e,t){for(var n=0;n{n.d(t,{r:()=>a});var r=n("./src/controller/watchshot.ts");function i(e){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function o(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(o=function(){return!!e})()}var a=/*#__PURE__*/function(e){var t;function n(e){var t,r,s,a;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,n),r=n,s=[e],r=i(r),(t=(a=o()?Reflect.construct(r,s||[],i(this).constructor):r.apply(this,s))&&("object"==(a&&"undefined"!=typeof Symbol&&a.constructor===Symbol?"symbol":typeof a)||"function"==typeof a)?a:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this)).container.table.cueball=t.container.rules.otherPlayersCueBall(),t.container.table.cue.moveTo(t.container.table.cueball.pos),t.container.view.camera.suggestMode(t.container.view.camera.topView),t}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}(n,e),t=[{key:"handleAim",value:function(e){return this.container.table.cue.aim=e,this.container.table.cueball.pos.copy(e.pos),this}},{key:"handleHit",value:function(e){return this.container.table.updateFromSerialised(e.tablejson),new r.O(this.container)}}],function(e,t){for(var n=0;n{n.d(t,{O:()=>u});var r=n("./src/controller/aim.ts"),i=n("./src/controller/watchaim.ts"),s=n("./src/controller/controllerbase.ts"),o=n("./src/controller/placeball.ts");function a(e){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function l(e,t){return(l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(c=function(){return!!e})()}var u=/*#__PURE__*/function(e){var t;function n(e){var t,r,i,s;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,n),r=n,i=[e],r=a(r),(t=(s=c()?Reflect.construct(r,i||[],a(this).constructor):r.apply(this,i))&&("object"==(s&&"undefined"!=typeof Symbol&&s.constructor===Symbol?"symbol":typeof s)||"function"==typeof s)?s:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this)).container.table.outcome=[],t.container.table.hit(),t}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&l(e,t)}(n,e),t=[{key:"handleStartAim",value:function(e){return new r.m(this.container)}},{key:"handlePlaceBall",value:function(e){return new o.x(this.container)}},{key:"handleWatch",value:function(e){return"rerack"in e.json?(console.log("Respot"),this.container.table.updateFromSerialised(e.json),this):new i.r(this.container)}}],function(e,t){for(var n=0;n{n.d(t,{h:()=>l});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function a(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(a=function(){return!!e})()}var l=/*#__PURE__*/function(e){var t;function n(){var e,t,r,o;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,n),t=s(t=n),(e=(o=a()?Reflect.construct(t,[],s(this).constructor):t.apply(this,r))&&("object"==(o&&"undefined"!=typeof Symbol&&o.constructor===Symbol?"symbol":typeof o)||"function"==typeof o)?o:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this)).type=i.B.ABORT,e}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&o(e,t)}(n,e),t=[{key:"applyToController",value:function(e){return e.handleAbort(this)}}],function(e,t){for(var n=0;n{n.d(t,{w:()=>f});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts"),s=n("./src/utils/utils.ts"),o=n("./node_modules/three/build/three.module.js");function a(e,t){for(var n=0;n{n.d(t,{u:()=>l});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function a(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(a=function(){return!!e})()}var l=/*#__PURE__*/function(e){var t;function n(){var e,t,r,o;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,n),t=s(t=n),(e=(o=a()?Reflect.construct(t,[],s(this).constructor):t.apply(this,r))&&("object"==(o&&"undefined"!=typeof Symbol&&o.constructor===Symbol?"symbol":typeof o)||"function"==typeof o)?o:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this)).type=i.B.BEGIN,e}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&o(e,t)}(n,e),t=[{key:"applyToController",value:function(e){return e.handleBegin(this)}}],function(e,t){for(var n=0;n{n.d(t,{W:()=>u});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function s(e,t){for(var n=0;n{n.d(t,{b:()=>u});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function s(e,t){for(var n=0;n{n.d(t,{B:()=>r});var r=/*#__PURE__*/function(e){return e.BEGIN="BEGIN",e.BREAK="BREAK",e.WATCHAIM="WATCHAIM",e.AIM="AIM",e.HIT="HIT",e.STATIONARY="STATIONARY",e.CHAT="CHAT",e.ABORT="ABORT",e.PLACEBALL="PLACEBALL",e.REJOIN="REJOIN",e.RERACK="RERACK",e.STARTAIM="STARTAIM",e}({})},"./src/events/gameevent.ts":(e,t,n)=>{function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}n.d(t,{F:()=>i});var i=function e(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,e),r(this,"type",void 0),r(this,"sequence",void 0)}},"./src/events/hitevent.ts":(e,t,n)=>{n.d(t,{Q:()=>c});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function s(e,t){for(var n=0;n{function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}n.d(t,{p:()=>i});var i=function e(t,n){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,e),r(this,"t",void 0),r(this,"key",void 0),this.t=t,this.key=n}},"./src/events/keyboard.ts":(e,t,n)=>{n.d(t,{s:()=>a});var r=n("./src/events/input.ts"),i=n("./node_modules/interactjs/dist/interact.min.js"),s=/*#__PURE__*/n.n(i);function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var a=/*#__PURE__*/function(){var e;function t(e){var n=this;!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),o(this,"pressed",{}),o(this,"released",{}),o(this,"keydown",function(e){null==n.pressed[e.code]&&(n.pressed[e.code]=performance.now()),e.stopImmediatePropagation(),"F12"!==e.key&&e.preventDefault()}),o(this,"keyup",function(e){n.released[e.code]=performance.now()-n.pressed[e.code],delete n.pressed[e.code],e.stopImmediatePropagation(),"F12"!==e.key&&e.preventDefault()}),o(this,"mousetouch",function(e){var t,r,i=n.released,s=e.client.yMath.abs(i.movementY)&&(i.movementY=0)}),this.addHandlers(e),/Android|iPhone/i.test(navigator.userAgent)||(e.contentEditable="true")}return e=[{key:"getEvents",value:function(){var e=this,t=Object.keys(this.pressed).filter(function(e){return!/Shift/.test(e)}).filter(function(e){return!/Control/.test(e)}),n=Object.keys(this.pressed).some(function(e){return/Shift/.test(e)}),i=Object.keys(this.pressed).some(function(e){return/Control/.test(e)}),s=[];return t.forEach(function(t){var o=performance.now()-e.pressed[t];s.push(new r.p(i?o/3:o,n?"Shift"+t:t)),"Space"!=t&&(e.pressed[t]=performance.now())}),Object.keys(this.released).forEach(function(t){return s.push(new r.p(e.released[t],t+"Up"))}),this.released={},s}},{key:"addHandlers",value:function(e){var t=this;e.addEventListener("keydown",this.keydown),e.addEventListener("keyup",this.keyup),e.focus(),s()(e).draggable({listeners:{move:function(e){t.mousetouch(e)}}}),s()(e).gesturable({onmove:function(e){e.dx/=3,t.mousetouch(e)}})}}],function(e,t){for(var n=0;n{n.d(t,{z:()=>h});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts"),s=n("./src/utils/utils.ts");function o(e,t){for(var n=0;n{n.d(t,{x:()=>c});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function s(e,t){for(var n=0;n{n.d(t,{M:()=>c});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function s(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:0;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,r),t=o(t=r),(s="foul")in(a=(e=l()?Reflect.construct(t,[],o(this).constructor):t.apply(this,n))&&("object"==(e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e)||"function"==typeof e)?e:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this))?Object.defineProperty(a,s,{value:0,enumerable:!0,configurable:!0,writable:!0}):a[s]=0,a.type=i.B.STARTAIM,a.foul=c,a}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&a(e,t)}(r,e),t=[{key:"applyToController",value:function(e){return e.handleStartAim(this)}}],n=[{key:"fromJson",value:function(e){return new r(e.foul)}}],t&&s(r.prototype,t),n&&s(r,n),r}(r.F)},"./src/events/stationaryevent.ts":(e,t,n)=>{n.d(t,{T:()=>l});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function a(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(a=function(){return!!e})()}var l=/*#__PURE__*/function(e){var t;function n(){var e,t,r,o;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,n),t=s(t=n),(e=(o=a()?Reflect.construct(t,[],s(this).constructor):t.apply(this,r))&&("object"==(o&&"undefined"!=typeof Symbol&&o.constructor===Symbol?"symbol":typeof o)||"function"==typeof o)?o:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this)).type=i.B.STATIONARY,e}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&o(e,t)}(n,e),t=[{key:"applyToController",value:function(e){return e.handleStationary(this)}}],function(e,t){for(var n=0;n{n.d(t,{Q:()=>c});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function s(e,t){for(var n=0;n{var r=n("./src/container/container.ts"),i=n("./src/events/keyboard.ts"),s=n("./src/events/eventtype.ts"),o=n("./src/events/aimevent.ts"),a=n("./src/events/watchevent.ts"),l=n("./src/events/hitevent.ts"),c=n("./src/events/abortevent.ts"),u=n("./src/events/breakevent.ts"),h=n("./src/events/beginevent.ts"),f=n("./src/events/chatevent.ts");function p(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:"",a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,r),t=v(t=r),d(i=(e=y()?Reflect.construct(t,[],v(this).constructor):t.apply(this,n))&&("object"==(e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e)||"function"==typeof e)?e:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this),"clientResendFrom",void 0),d(i,"serverResendFrom",void 0),i.type=s.B.REJOIN,i.clientResendFrom=o,i.serverResendFrom=a,i}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&m(e,t)}(r,e),t=[{key:"applyToController",value:function(e){return e.handleRejoin(this)}}],n=[{key:"fromJson",value:function(e){return new r(e.clientResendFrom,e.serverResendFrom)}}],t&&p(r.prototype,t),n&&p(r,n),r}(n("./src/events/gameevent.ts").F),g=n("./src/events/placeballevent.ts"),w=n("./src/events/rerackevent.ts"),k=n("./src/events/startaimevent.ts"),T=/*#__PURE__*/function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t)}return e=[{key:"serialise",value:function(e){return JSON.stringify(e)}},{key:"fromJson",value:function(e){switch(e.type){case s.B.BEGIN:return new h.u;case s.B.AIM:return o.w.fromJson(e);case s.B.BREAK:return u.W.fromJson(e);case s.B.WATCHAIM:return a.Q.fromJson(e.json);case s.B.HIT:return l.Q.fromJson(e);case s.B.CHAT:return f.b.fromJson(e);case s.B.REJOIN:return b.fromJson(e);case s.B.ABORT:return new c.h;case s.B.PLACEBALL:return g.z.fromJson(e);case s.B.RERACK:return w.x.fromJson(e);case s.B.STARTAIM:return k.M.fromJson(e);default:throw Error("Unknown GameEvent :"+e)}}},{key:"fromSerialised",value:function(e){var n=JSON.parse(e),r=t.fromJson(n);return"sequence"in n&&(r.sequence=n.sequence),r}}],function(e,t){for(var n=0;n upload high score \uD83C\uDFC6{n.d(t,{c:()=>d,U:()=>p});var r=n("./src/utils/utils.ts"),i=n("./src/model/physics/physics.ts"),s=n("./node_modules/three/build/three.module.js"),o=n("./src/model/physics/constants.ts");function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var l=/*#__PURE__*/function(){var e;function t(e,n){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),a(this,"line",void 0),a(this,"geometry",void 0),a(this,"positions",void 0),a(this,"lastPos",new s.Pq0),a(this,"lastVel",new s.Pq0),this.geometry=new s.LoY,this.positions=new Float32Array(3*e),this.geometry.setAttribute("position",new s.THS(this.positions,3)),this.reset();var r=new s.mrM({color:n,opacity:.25,linewidth:3,transparent:!0});this.line=new s.N1A(this.geometry,r),this.line.visible=!1}return e=[{key:"reset",value:function(){this.geometry.setDrawRange(0,0),this.lastVel.setZ(1)}},{key:"forceTrace",value:function(e){this.lastVel.z=1,this.addTraceGiven(e,this.lastVel,1,.1,1)}},{key:"addTrace",value:function(e,t){if(0!==t.length()){var n=this.lastVel.angleTo(t),r=n>Math.PI/32?.01*o.R:o.R,i=this.lastPos.distanceTo(e);this.addTraceGiven(e,t,i,r,n)}}},{key:"addTraceGiven",value:function(e,t,n,r,i){var s=this.geometry.drawRange.count;0!==s&&n1&&i<1e-4&&s--,this.lastPos.copy(e),this.lastVel.copy(t),this.addPoint(e,s))}},{key:"addPoint",value:function(e,t){var n=3*t;n>this.positions.length||(this.positions[n++]=e.x,this.positions[n++]=e.y,this.positions[n]=e.z,this.geometry.setDrawRange(0,t+1),this.line.geometry.attributes.position.needsUpdate=!0)}}],function(e,t){for(var n=0;nMath.abs(this.rvel.z))&&(this.setStationary(),!0)}},{key:"setStationary",value:function(){this.vel.copy(r.v_),this.rvel.copy(r.v_),this.state="Stationary"}},{key:"isRolling",value:function(){return 0!==this.vel.lengthSq()&&0!==this.rvel.lengthSq()&&(0,i.Mq)(this.vel,this.rvel).length(){function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}n.d(t,{P:()=>i});var i=/*#__PURE__*/function(){var e;function t(e,n,i,s){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),r(this,"type",void 0),r(this,"timestamp",void 0),r(this,"ballA",null),r(this,"ballB",null),r(this,"incidentSpeed",void 0),this.type=e,this.ballA=n,this.ballB=i,this.incidentSpeed=s,this.timestamp=Date.now()}return e=[{key:"pot",value:function(e,n){return new t("Pot",e,e,n)}},{key:"cushion",value:function(e,n){return new t("Cushion",e,e,n)}},{key:"collision",value:function(e,n,r){return new t("Collision",e,n,r)}},{key:"hit",value:function(e,n){return new t("Hit",e,e,n)}},{key:"isCueBallPotted",value:function(e,t){return t.some(function(t){return"Pot"==t.type&&t.ballA===e})}},{key:"isBallPottedNoFoul",value:function(e,n){return n.some(function(e){return"Pot"==e.type&&null!==e.ballA})&&!t.isCueBallPotted(e,n)}},{key:"pots",value:function(e){return e.filter(function(e){return"Pot"==e.type}).map(function(e){return e.ballA})}},{key:"potCount",value:function(e){return this.pots(e).length}},{key:"onlyRedsPotted",value:function(e){return this.pots(e).every(function(e){return e.id>6})}},{key:"firstCollision",value:function(e){var t=e.filter(function(e){return"Collision"===e.type});return t.length>0?t[0]:void 0}},{key:"isClearTable",value:function(e){var t=e.balls.filter(function(e){return e.onTable()});return 1===t.length&&t[0]===e.cueball}},{key:"isThreeCushionPoint",value:function(e,n){n=t.cueBallFirst(e,n).filter(function(t){return t.ballA===e});var r=new Set,i=0,s=!0,o=!1,a=void 0;try{for(var l,c=n[Symbol.iterator]();!(s=(l=c.next()).done);s=!0){var u=l.value;if("Cushion"===u.type&&i++,"Collision"===u.type&&(r.add(u.ballB),2===r.size))return i>=3}}catch(e){o=!0,a=e}finally{try{s||null==c.return||c.return()}finally{if(o)throw a}}return!1}},{key:"cueBallFirst",value:function(e,t){return t.forEach(function(t){"Collision"===t.type&&t.ballB===e&&(t.ballB=t.ballA,t.ballA=e)}),t}}],function(e,t){for(var n=0;n{n.d(t,{M:()=>r,R:()=>i,_:()=>a,ee:()=>s,o:()=>o});var r=.1406,i=.02625,s=.98,o=.212,a=.14},"./src/model/physics/claude/qwen.ts":(e,t,n)=>{n.d(t,{z:()=>s});var r=n("./src/model/physics/constants.ts");function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var s=/*#__PURE__*/function(){var e;function t(e,n,r,s,o){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),i(this,"P",0),i(this,"WzI",0),i(this,"vx",void 0),i(this,"vy",void 0),i(this,"ωx",void 0),i(this,"ωy",void 0),i(this,"ωz",void 0),i(this,"s",void 0),i(this,"φ",void 0),i(this,"sʹ",void 0),i(this,"φʹ",void 0),i(this,"i",0),i(this,"N",100),i(this,"M",void 0),i(this,"R",void 0),i(this,"μs",void 0),i(this,"μw",void 0),i(this,"ee",void 0),this.M=e,this.R=n,this.ee=r,this.μs=s,this.μw=o}return e=[{key:"updateSlipSpeedsAndAngles",value:function(){var e=this.R,t=this.vx+this.ωy*e*r.Z3-this.ωz*e*r.o5,n=-this.vy*r.Z3+this.ωx*e,i=this.vx-this.ωy*e,s=this.vy+this.ωx*e;this.s=Math.sqrt(Math.pow(t,2)+Math.pow(n,2)),this.φ=Math.atan2(n,t),this.φ<0&&(this.φ+=2*Math.PI),this.sʹ=Math.sqrt(Math.pow(i,2)+Math.pow(s,2)),this.φʹ=Math.atan2(s,i),this.φʹ<0&&(this.φʹ+=2*Math.PI)}},{key:"compressionPhase",value:function(){for(var e=Math.max(this.M*this.vy/this.N,.001);this.vy>0;)this.updateSingleStep(e)}},{key:"restitutionPhase",value:function(e){var t=Math.max(e/this.N,.001);for(this.WzI=0;this.WzI10*this.N)throw"Solution not found"}},{key:"updateVelocity",value:function(e){var t=this.μs,n=this.μw,i=this.M;this.vx-=1/i*(n*Math.cos(this.φ)+t*Math.cos(this.φʹ)*(r.Z3+n*Math.sin(this.φ)*r.o5))*e,this.vy-=1/i*(r.o5-n*r.Z3*Math.sin(this.φ)+t*Math.sin(this.φʹ)*(r.Z3+n*Math.sin(this.φ)*r.o5))*e}},{key:"updateAngularVelocity",value:function(e){var t=this.μs,n=this.μw,i=this.M,s=this.R;this.ωx+=-(5/(2*i*s))*(n*Math.sin(this.φ)+t*Math.sin(this.φʹ)*(r.Z3+n*Math.sin(this.φ)*r.o5))*e,this.ωy+=-(5/(2*i*s))*(n*Math.cos(this.φ)*r.Z3-t*Math.cos(this.φʹ)*(r.Z3+n*Math.sin(this.φ)*r.o5))*e,this.ωz+=5/(2*i*s)*(n*Math.cos(this.φ)*r.o5)*e}},{key:"updateWorkDone",value:function(e){var t=e*Math.abs(this.vy);this.WzI+=t,this.P+=e}},{key:"solvePaper",value:function(e,t,n,r){this.solve(e*Math.cos(t),e*Math.sin(t),-r*Math.sin(t),r*Math.cos(t),n)}},{key:"solve",value:function(e,t,n,r,i){this.vx=e,this.vy=t,this.ωx=n,this.ωy=r,this.ωz=i,this.WzI=0,this.P=0,this.i=0,this.compressionPhase();var s=this.WzI-(1-this.ee*this.ee)*this.WzI;this.restitutionPhase(s)}}],function(e,t){for(var n=0;n{n.d(t,{I:()=>s,Mz:()=>r,Qg:()=>b,R:()=>f,Wv:()=>w,Ys:()=>k,Z3:()=>d,cM:()=>T,e:()=>p,g:()=>o,gT:()=>c,gf:()=>l,jG:()=>y,kL:()=>u,kM:()=>A,m:()=>h,mu:()=>a,o5:()=>v,x3:()=>i,xO:()=>g});var r,i,s,o=9.8,a=.00985,l=.16,c=.8,u=.034,h=.23,f=.03275,p=.86,d=.4,v=Math.sqrt(21)/5;function m(){r=a*h*o*2/3*u,i=7/(5*Math.sqrt(2))*f*a*h*o,s=.4*h*f*f}function y(e){f=e,m()}function b(e){h=e,m()}function g(e){a=e,m()}function w(e){u=e,m()}function k(e){l=e}function T(e){p=e}function A(e){c=e}m()},"./src/model/physics/knuckle.ts":(e,t,n)=>{n.d(t,{O:()=>a});var r=n("./src/model/physics/constants.ts"),i=n("./src/view/pocketgeometry.ts");function s(e,t){for(var n=0;n{n.d(t,{$8:()=>S,Gp:()=>k,JD:()=>f,Mq:()=>c,QK:()=>d,QV:()=>R,Qy:()=>M,Un:()=>w,c0:()=>g,lx:()=>p,p2:()=>h,s0:()=>b,t6:()=>_,yO:()=>T});var r=n("./node_modules/three/build/three.module.js"),i=n("./src/utils/utils.ts"),s=n("./src/model/physics/constants.ts"),o=n("./src/model/physics/claude/qwen.ts"),a=n("./src/model/physics/claude/constants.ts"),l=new r.Pq0;function c(e,t){return l.copy(e).addScaledVector((0,i.KM)(t),s.R)}var u={v:new r.Pq0,w:new r.Pq0};function h(e,t){var n=c(e,t).setZ(0);return u.v.copy((0,i.xb)(n).multiplyScalar(-s.gf*s.g)),u.w.copy((0,i.xb)((0,i.KM)(n)).multiplyScalar(2.5*s.gf*s.g/s.R)),u.w.setZ(-2.5*(s.Mz/(s.m*s.R*s.R))*Math.sign(t.z)),u}function f(e){var t=new r.Pq0(e.x,e.y,0).length(),n=5/7*s.x3/(s.m*s.R)/t,i=5/7*s.x3/(s.m*s.R*s.R)/t;return u.v.set(-n*e.y,n*e.x,0),u.w.set(-i*e.x,-i*e.y,-2.5*(s.Mz/(s.m*s.R*s.R))*Math.sign(e.z)),u}function p(e,t){var n=t.z;t.copy((0,i.KM)(e).multiplyScalar(1/s.R)),t.setZ(n)}function d(e,t,n,r){var s=r(t.clone().applyAxisAngle(i.up,e),n.clone().applyAxisAngle(i.up,e));return s.v.applyAxisAngle(i.up,-e),s.w.applyAxisAngle(i.up,-e),s}Object.freeze(u);var v=Math.asin(.1*s.R/s.R),m=Math.sin(v),y=Math.cos(v);function b(e,t){return new r.Pq0(e.x*m-e.z*y+s.R*t.y,-e.y-s.R*t.z*y+s.R*t.x*m)}function g(e){return e.x*y}function w(e){var t=3.5/s.m;return e.length()/t}function k(e){var t,n=1/s.m,i=.39+.257*(t=new r.Pq0(e/y,0,0)).x-.044*t.x*t.x;return s.gT*((1+i)*e)/n}function T(e,t){var n=k(g(e));return w(b(e,t))<=n}function A(e,t){return{c:g(e),s:b(e,t),A:3.5/s.m,B:1/s.m}}function x(e,t){var n=A(e,t),r=n.c,i=n.s,o=n.A,a=n.B,l=(1+s.e)*(r/a);return E(-i.x/o*m-l*y,i.y/o,i.x/o*y-l*m)}function P(e,t){var n=A(e,t),r=n.c,i=n.B,o=(1+s.e)*(r/i),a=.471-.241*Math.atan2(Math.abs(e.y),e.x),l=Math.atan2(e.y,e.x),c=Math.cos(l);return E(-a*o*c*y-o*y,a*o*Math.sin(l),a*o*c*y-o*m)}function R(e,t){return T(e,t)?x(e,t):P(e,t)}function S(e,t){var n=x(e,t),r=P(e,t),i=Math.sign(e.y)===Math.sign(t.z)?Math.cos(Math.atan2(e.y,e.x)):1;return{v:r.v.lerp(n.v,i),w:r.w.lerp(n.w,i)}}function E(e,t,n){return{v:new r.Pq0(e/s.m,t/s.m),w:new r.Pq0(-s.R/s.I*t*m,s.R/s.I*(e*m-n*y),s.R/s.I*t*y)}}function O(e,t){var n=new o.z(s.m,s.R,a.ee,a.o,a._+.1);n.solve(e.x,e.y,t.x,t.y,t.z);var i=new r.Pq0(n.vx,n.vy,0),l=new r.Pq0(n.ωx,n.ωy,n.ωz);return{v:i.sub(e),w:l.sub(t)}}function M(e,t){return d(Math.PI/2,e,t,O)}function _(e,t){var n=Math.atan2(-e.x,e.y),r=2.5*t.length()*(e.length()*s.R)/(s.R*s.R),o=t.clone().normalize();return(0,i.KM)(o).applyAxisAngle(o,n).multiplyScalar(r)}},"./src/model/physics/pocket.ts":(e,t,n)=>{n.d(t,{Z:()=>l});var r=n("./src/model/ball.ts"),i=n("./src/model/physics/constants.ts"),s=n("./src/utils/utils.ts");function o(e,t){for(var n=0;nthis.radius-i.R){var o=this.pos.clone().sub(e.pos).normalize().setZ(0);n>-i.R/2&&(e.vel.addScaledVector(o,7*i.R*t*i.g),e.rvel.addScaledVector((0,s.KM)(o),7*t*i.g)),0>e.vel.dot(o)&&(e.ballmesh.trace.forceTrace(e.pos),e.vel.x=o.x*e.vel.length()/2,e.vel.y=o.y*e.vel.length()/2)}var a=this.restingDepth(e);n{n.d(t,{X:()=>b});var r=n("./src/view/tablegeometry.ts"),i=n("./src/model/physics/physics.ts"),s=n("./src/view/pocketgeometry.ts"),o=/*#__PURE__*/function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t)}return e=[{key:"bounceAny",value:function(e,n){var s=!(arguments.length>2)||void 0===arguments[2]||arguments[2],o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:i.$8,a=e.futurePosition(n);if(t.willBounceLong(a,s)){var l=a.y>r.P.tableY?-Math.PI/2:Math.PI/2;return t.bounceIn(l,e,o)}if(t.willBounceShort(a,s)){var c=a.x>r.P.tableX?0:Math.PI;return t.bounceIn(c,e,o)}}},{key:"willBounceShort",value:function(e,n){return n?t.willBounceShortSegment(s.f.pockets.pocketNW.knuckleSW.pos.y,s.f.pockets.pocketSW.knuckleNW.pos.y,e):t.willBounceShortSegment(r.P.Y,-r.P.Y,e)}},{key:"willBounceLong",value:function(e,n){return n?t.willBounceLongSegment(s.f.pockets.pocketNW.knuckleNE.pos.x,s.f.pockets.pocketN.knuckleNW.pos.x,e)||t.willBounceLongSegment(s.f.pockets.pocketN.knuckleNE.pos.x,s.f.pockets.pocketNE.knuckleNW.pos.x,e):t.willBounceLongSegment(-r.P.X,r.P.X,e)}},{key:"willBounceLongSegment",value:function(e,t,n){return n.x>e&&n.xr.P.tableY}},{key:"willBounceShortSegment",value:function(e,t,n){return n.y>t&&n.yr.P.tableX}},{key:"bounceIn",value:function(e,t,n){t.ballmesh.trace.forceTrace(t.futurePos);var r=(0,i.QK)(e,t.vel,t.rvel,n);return t.vel.add(r.v),t.rvel.add(r.w),r.v.length()}}],function(e,t){for(var n=0;n100)throw Error("Depth exceeded resolving collisions");this.balls.forEach(function(t){t.update(e)})}},{key:"prepareAdvanceAll",value:function(e){var t=this;return this.pairs.every(function(n){return t.prepareAdvancePair(n.a,n.b,e)})&&this.balls.every(function(n){return t.prepareAdvanceToCushions(n,e)})}},{key:"prepareAdvancePair",value:function(e,t,n){if(u.willCollide(e,t,n)){var r=u.collide(e,t);return this.outcome.push(v.P.collision(e,t,r)),!1}return!0}},{key:"prepareAdvanceToCushions",value:function(e,t){if(!e.onTable())return!0;var n=e.futurePosition(t);if(Math.abs(n.y)1&&void 0!==arguments[1]?arguments[1]:this.cueball;return this.balls.filter(function(e){return e!==t}).some(function(t){return t.pos.distanceTo(e)<2*c.R})}}],t=[{key:"fromSerialised",value:function(e){var t=new n(e.balls.map(function(e){return l.c.fromSerialised(e)}));return t.updateFromSerialised(e),t}}],e&&m(n.prototype,e),t&&m(n,t),n}()},"./src/utils/gltf.ts":(e,t,n)=>{n.d(t,{KP:()=>eR,Ro:()=>eS});var r=n("./node_modules/three/build/three.module.js");let i={POSITION:["byte","byte normalized","unsigned byte","unsigned byte normalized","short","short normalized","unsigned short","unsigned short normalized"],NORMAL:["byte normalized","short normalized"],TANGENT:["byte normalized","short normalized"],TEXCOORD:["byte","byte normalized","unsigned byte","short","short normalized","unsigned short"]};class s{constructor(){this.textureUtils=null,this.pluginCallbacks=[],this.register(function(e){return new y(e)}),this.register(function(e){return new b(e)}),this.register(function(e){return new T(e)}),this.register(function(e){return new A(e)}),this.register(function(e){return new x(e)}),this.register(function(e){return new P(e)}),this.register(function(e){return new g(e)}),this.register(function(e){return new w(e)}),this.register(function(e){return new k(e)}),this.register(function(e){return new R(e)}),this.register(function(e){return new S(e)}),this.register(function(e){return new E(e)}),this.register(function(e){return new O(e)}),this.register(function(e){return new M(e)})}register(e){return -1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return -1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}setTextureUtils(e){return this.textureUtils=e,this}parse(e,t,n,r){let i=new m,s=[];for(let e=0,t=this.pluginCallbacks.length;ee.toBlob(n,t)):("image/jpeg"===t?n=.92:"image/webp"===t&&(n=.8),e.convertToBlob({type:t,quality:n}))}class m{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.extensionsRequired={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter r"+r.sPf}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map},this.textureUtils=null}setPlugins(e){this.plugins=e}setTextureUtils(e){this.textureUtils=e}async writeAsync(e,t,n={}){this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},n),this.options.animations.length>0&&(this.options.trs=!0),await this.processInputAsync(e),await Promise.all(this.pending);let r=this.buffers,i=this.json;n=this.options;let s=this.extensionsUsed,o=this.extensionsRequired,a=new Blob(r,{type:"application/octet-stream"}),l=Object.keys(s),c=Object.keys(o);if(l.length>0&&(i.extensionsUsed=l),c.length>0&&(i.extensionsRequired=c),i.buffers&&i.buffers.length>0&&(i.buffers[0].byteLength=a.size),!0===n.binary){let e=new FileReader;e.readAsArrayBuffer(a),e.onloadend=function(){var n;let r=p(e.result),s=new DataView(new ArrayBuffer(8));s.setUint32(0,r.byteLength,!0),s.setUint32(4,5130562,!0);let o=p((n=JSON.stringify(i),new TextEncoder().encode(n).buffer),32),a=new DataView(new ArrayBuffer(8));a.setUint32(0,o.byteLength,!0),a.setUint32(4,0x4e4f534a,!0);let l=new ArrayBuffer(12),c=new DataView(l);c.setUint32(0,0x46546c67,!0),c.setUint32(4,2,!0);let u=12+a.byteLength+o.byteLength+s.byteLength+r.byteLength;c.setUint32(8,u,!0);let h=new Blob([l,a,o,s,r],{type:"application/octet-stream"}),f=new FileReader;f.readAsArrayBuffer(h),f.onloadend=function(){t(f.result)}}}else if(i.buffers&&i.buffers.length>0){let e=new FileReader;e.readAsDataURL(a),e.onloadend=function(){let n=e.result;i.buffers[0].uri=n,t(i)}}else t(i)}serializeUserData(e,t){if(0===Object.keys(e.userData).length)return;let n=this.options,r=this.extensionsUsed;try{let i=JSON.parse(JSON.stringify(e.userData));if(n.includeCustomExtensions&&i.gltfExtensions){for(let e in void 0===t.extensions&&(t.extensions={}),i.gltfExtensions)t.extensions[e]=i.gltfExtensions[e],r[e]=!0;delete i.gltfExtensions}Object.keys(i).length>0&&(t.extras=i)}catch(t){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+t.message)}}getUID(e,t=!1){if(!1===this.uids.has(e)){let t=new Map;t.set(!0,this.uid++),t.set(!1,this.uid++),this.uids.set(e,t)}return this.uids.get(e).get(t)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;let t=new r.Pq0;for(let n=0,r=e.count;n5e-4)return!1;return!0}createNormalizedNormalAttribute(e){let t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);let n=e.clone(),i=new r.Pq0;for(let e=0,t=n.count;e4?i=e.array[s*e.itemSize+n]:(0===n?i=e.getX(s):1===n?i=e.getY(s):2===n?i=e.getZ(s):3===n&&(i=e.getW(s)),!0===e.normalized&&(i=r.cj9.normalize(i,e.array))),t===o.FLOAT?h.setFloat32(p,i,!0):t===o.INT?h.setInt32(p,i,!0):t===o.UNSIGNED_INT?h.setUint32(p,i,!0):t===o.SHORT?h.setInt16(p,i,!0):t===o.UNSIGNED_SHORT?h.setUint16(p,i,!0):t===o.BYTE?h.setInt8(p,i):t===o.UNSIGNED_BYTE&&h.setUint8(p,i),p+=a}p%c!=0&&(p+=c-p%c)}let d={buffer:this.processBuffer(h.buffer),byteOffset:this.byteOffset,byteLength:u};return void 0!==s&&(d.target=s),s===o.ARRAY_BUFFER&&(d.byteStride=c),this.byteOffset+=u,l.bufferViews.push(d),{id:l.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){let t=this,n=t.json;return n.bufferViews||(n.bufferViews=[]),new Promise(function(r){let i=new FileReader;i.readAsArrayBuffer(e),i.onloadend=function(){let e=p(i.result),s={buffer:t.processBuffer(e),byteOffset:t.byteOffset,byteLength:e.byteLength};t.byteOffset+=e.byteLength,r(n.bufferViews.push(s)-1)}})}processAccessor(e,t,n,i){let s,a;let l=this.json;if(e.array.constructor===Float32Array)s=o.FLOAT;else if(e.array.constructor===Int32Array)s=o.INT;else if(e.array.constructor===Uint32Array)s=o.UNSIGNED_INT;else if(e.array.constructor===Int16Array)s=o.SHORT;else if(e.array.constructor===Uint16Array)s=o.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)s=o.BYTE;else if(e.array.constructor===Uint8Array)s=o.UNSIGNED_BYTE;else throw Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+e.array.constructor.name);if(void 0===n&&(n=0),(void 0===i||i===1/0)&&(i=e.count),0===i)return null;let c=function(e,t,n){let i={min:Array(e.itemSize).fill(Number.POSITIVE_INFINITY),max:Array(e.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let s=t;s4?n=e.array[s*e.itemSize+t]:(0===t?n=e.getX(s):1===t?n=e.getY(s):2===t?n=e.getZ(s):3===t&&(n=e.getW(s)),!0===e.normalized&&(n=r.cj9.normalize(n,e.array))),i.min[t]=Math.min(i.min[t],n),i.max[t]=Math.max(i.max[t],n)}return i}(e,n,i);void 0!==t&&(a=e===t.index?o.ELEMENT_ARRAY_BUFFER:o.ARRAY_BUFFER);let u=this.processBufferView(e,s,n,i,a),h={bufferView:u.id,byteOffset:u.byteOffset,componentType:s,count:i,max:c.max,min:c.min,type:{1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"}[e.itemSize]};return!0===e.normalized&&(h.normalized=!0),l.accessors||(l.accessors=[]),l.accessors.push(h)-1}processImage(e,t,n,i="image/png"){if(null!==e){let s=this,o=s.cache,a=s.json,l=s.options,c=s.pending;o.images.has(e)||o.images.set(e,{});let u=o.images.get(e),h=i+":flipY/"+n.toString();if(void 0!==u[h])return u[h];a.images||(a.images=[]);let f={mimeType:i},p=d();p.width=Math.min(e.width,l.maxTextureSize),p.height=Math.min(e.height,l.maxTextureSize);let m=p.getContext("2d",{willReadFrequently:!0});if(!0===n&&(m.translate(0,p.height),m.scale(1,-1)),void 0!==e.data){t!==r.GWd&&console.error("GLTFExporter: Only RGBAFormat is supported.",t),(e.width>l.maxTextureSize||e.height>l.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);let n=new Uint8ClampedArray(e.height*e.width*4);for(let t=0;ts.processBufferViewImage(e)).then(e=>{f.bufferView=e})):void 0!==p.toDataURL?f.uri=p.toDataURL(i):c.push(v(p,i).then(e=>new FileReader().readAsDataURL(e)).then(e=>{f.uri=e}));let y=a.images.push(f)-1;return u[h]=y,y}throw Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(e){let t=this.json;t.samplers||(t.samplers=[]);let n={magFilter:l[e.magFilter],minFilter:l[e.minFilter],wrapS:l[e.wrapS],wrapT:l[e.wrapT]};return t.samplers.push(n)-1}async processTextureAsync(e){let t=this.options,n=this.cache,i=this.json;if(n.textures.has(e))return n.textures.get(e);i.textures||(i.textures=[]),e instanceof r.FvD&&(e=await this.decompressTextureAsync(e,t.maxTextureSize));let s=e.userData.mimeType;"image/webp"===s&&(s="image/png");let o={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,s)};e.name&&(o.name=e.name),await this._invokeAllAsync(async function(t){t.writeTexture&&await t.writeTexture(e,o)});let a=i.textures.push(o)-1;return n.textures.set(e,a),a}async processMaterialAsync(e){let t=this.cache,n=this.json;if(t.materials.has(e))return t.materials.get(e);if(e.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;n.materials||(n.materials=[]);let i={pbrMetallicRoughness:{}};!0!==e.isMeshStandardMaterial&&!0!==e.isMeshBasicMaterial&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");let s=e.color.toArray().concat([e.opacity]);if(h(s,[1,1,1,1])||(i.pbrMetallicRoughness.baseColorFactor=s),e.isMeshStandardMaterial?(i.pbrMetallicRoughness.metallicFactor=e.metalness,i.pbrMetallicRoughness.roughnessFactor=e.roughness):(i.pbrMetallicRoughness.metallicFactor=0,i.pbrMetallicRoughness.roughnessFactor=1),e.metalnessMap||e.roughnessMap){let t=await this.buildMetalRoughTextureAsync(e.metalnessMap,e.roughnessMap),n={index:await this.processTextureAsync(t),texCoord:t.channel};this.applyTextureTransform(n,t),i.pbrMetallicRoughness.metallicRoughnessTexture=n}if(e.map){let t={index:await this.processTextureAsync(e.map),texCoord:e.map.channel};this.applyTextureTransform(t,e.map),i.pbrMetallicRoughness.baseColorTexture=t}if(e.emissive){let t=e.emissive;if(Math.max(t.r,t.g,t.b)>0&&(i.emissiveFactor=e.emissive.toArray()),e.emissiveMap){let t={index:await this.processTextureAsync(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(t,e.emissiveMap),i.emissiveTexture=t}}if(e.normalMap){let t={index:await this.processTextureAsync(e.normalMap),texCoord:e.normalMap.channel};e.normalScale&&1!==e.normalScale.x&&(t.scale=e.normalScale.x),this.applyTextureTransform(t,e.normalMap),i.normalTexture=t}if(e.aoMap){let t={index:await this.processTextureAsync(e.aoMap),texCoord:e.aoMap.channel};1!==e.aoMapIntensity&&(t.strength=e.aoMapIntensity),this.applyTextureTransform(t,e.aoMap),i.occlusionTexture=t}e.transparent?i.alphaMode="BLEND":e.alphaTest>0&&(i.alphaMode="MASK",i.alphaCutoff=e.alphaTest),e.side===r.$EB&&(i.doubleSided=!0),""!==e.name&&(i.name=e.name),this.serializeUserData(e,i),await this._invokeAllAsync(async function(t){t.writeMaterialAsync&&await t.writeMaterialAsync(e,i)});let o=n.materials.push(i)-1;return t.materials.set(e,o),o}async processMeshAsync(e){let t;let n=this.cache,i=this.json,a=[e.geometry.uuid];if(Array.isArray(e.material))for(let t=0,n=e.material.length;t0){let t=[],r=[],i={};if(void 0!==e.morphTargetDictionary)for(let t in e.morphTargetDictionary)i[e.morphTargetDictionary[t]]=t;for(let s=0;s0&&(u.extras={},u.extras.targetNames=r)}let y=Array.isArray(e.material);if(y&&0===c.groups.length)return null;let b=!1;if(y&&null===c.index){let e=[];for(let t=0,n=c.attributes.position.count;t0&&(r.targets=p),null!==c.index){let t=this.getUID(c.index);(void 0!==w[e].start||void 0!==w[e].count)&&(t+=":"+w[e].start+":"+w[e].count),n.attributes.has(t)?r.indices=n.attributes.get(t):(r.indices=this.processAccessor(c.index,c,w[e].start,w[e].count),n.attributes.set(t,r.indices)),null===r.indices&&delete r.indices}let i=await this.processMaterialAsync(g[w[e].materialIndex]);null!==i&&(r.material=i),f.push(r)}!0===b&&c.setIndex(null),u.primitives=f,i.meshes||(i.meshes=[]),await this._invokeAllAsync(function(t){t.writeMesh&&t.writeMesh(e,u)});let k=i.meshes.push(u)-1;return n.meshes.set(l,k),k}detectMeshQuantization(e,t){let n;if(this.extensionsUsed[a])return;switch(t.array.constructor){case Int8Array:n="byte";break;case Uint8Array:n="unsigned byte";break;case Int16Array:n="short";break;case Uint16Array:n="unsigned short";break;default:return}t.normalized&&(n+=" normalized");let r=e.split("_",1)[0];i[r]&&i[r].includes(n)&&(this.extensionsUsed[a]=!0,this.extensionsRequired[a]=!0)}processCamera(e){let t=this.json;t.cameras||(t.cameras=[]);let n=e.isOrthographicCamera,i={type:n?"orthographic":"perspective"};return n?i.orthographic={xmag:2*e.right,ymag:2*e.top,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:i.perspective={aspectRatio:e.aspect,yfov:r.cj9.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},""!==e.name&&(i.name=e.type),t.cameras.push(i)-1}processAnimation(e,t){let n=this.json,i=this.nodeMap;n.animations||(n.animations=[]);let o=(e=s.Utils.mergeMorphTargetTracks(e.clone(),t)).tracks,a=[],l=[];for(let e=0;e0){let t=[];for(let r=0,i=e.children.length;r0&&(i.children=t)}await this._invokeAllAsync(function(t){t.writeNode&&t.writeNode(e,i)});let s=t.nodes.push(i)-1;return r.set(e,s),s}async processSceneAsync(e){let t=this.json,n=this.options;t.scenes||(t.scenes=[],t.scene=0);let r={};""!==e.name&&(r.name=e.name),t.scenes.push(r);let i=[];for(let t=0,r=e.children.length;t0&&(r.nodes=i),this.serializeUserData(e,r)}async processObjectsAsync(e){let t=new r.Z58;t.name="AuxScene";for(let n=0;n0&&await this.processObjectsAsync(n);for(let e=0;e0&&(s.range=e.distance)):e.isSpotLight&&(s.type="spot",e.distance>0&&(s.range=e.distance),s.spot={},s.spot.innerConeAngle=(1-e.penumbra)*e.angle,s.spot.outerConeAngle=e.angle),void 0!==e.decay&&2!==e.decay&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),e.target&&(e.target.parent!==e||0!==e.target.position.x||0!==e.target.position.y||-1!==e.target.position.z)&&console.warn("THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."),i[this.name]||(r.extensions=r.extensions||{},r.extensions[this.name]={lights:[]},i[this.name]=!0);let o=r.extensions[this.name].lights;o.push(s),t.extensions=t.extensions||{},t.extensions[this.name]={light:o.length-1}}}class b{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}async writeMaterialAsync(e,t){if(!e.isMeshBasicMaterial)return;let n=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},n[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}}class g{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||0===e.clearcoat)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.clearcoatFactor=e.clearcoat,e.clearcoatMap){let t={index:await n.processTextureAsync(e.clearcoatMap),texCoord:e.clearcoatMap.channel};n.applyTextureTransform(t,e.clearcoatMap),i.clearcoatTexture=t}if(i.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){let t={index:await n.processTextureAsync(e.clearcoatRoughnessMap),texCoord:e.clearcoatRoughnessMap.channel};n.applyTextureTransform(t,e.clearcoatRoughnessMap),i.clearcoatRoughnessTexture=t}if(e.clearcoatNormalMap){let t={index:await n.processTextureAsync(e.clearcoatNormalMap),texCoord:e.clearcoatNormalMap.channel};1!==e.clearcoatNormalScale.x&&(t.scale=e.clearcoatNormalScale.x),n.applyTextureTransform(t,e.clearcoatNormalMap),i.clearcoatNormalTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class w{constructor(e){this.writer=e,this.name="KHR_materials_dispersion"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||0===e.dispersion)return;let n=this.writer.extensionsUsed,r={};r.dispersion=e.dispersion,t.extensions=t.extensions||{},t.extensions[this.name]=r,n[this.name]=!0}}class k{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||0===e.iridescence)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.iridescenceFactor=e.iridescence,e.iridescenceMap){let t={index:await n.processTextureAsync(e.iridescenceMap),texCoord:e.iridescenceMap.channel};n.applyTextureTransform(t,e.iridescenceMap),i.iridescenceTexture=t}if(i.iridescenceIor=e.iridescenceIOR,i.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],i.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){let t={index:await n.processTextureAsync(e.iridescenceThicknessMap),texCoord:e.iridescenceThicknessMap.channel};n.applyTextureTransform(t,e.iridescenceThicknessMap),i.iridescenceThicknessTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class T{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.transmissionFactor=e.transmission,e.transmissionMap){let t={index:await n.processTextureAsync(e.transmissionMap),texCoord:e.transmissionMap.channel};n.applyTextureTransform(t,e.transmissionMap),i.transmissionTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class A{constructor(e){this.writer=e,this.name="KHR_materials_volume"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.thicknessFactor=e.thickness,e.thicknessMap){let t={index:await n.processTextureAsync(e.thicknessMap),texCoord:e.thicknessMap.channel};n.applyTextureTransform(t,e.thicknessMap),i.thicknessTexture=t}e.attenuationDistance!==1/0&&(i.attenuationDistance=e.attenuationDistance),i.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class x{constructor(e){this.writer=e,this.name="KHR_materials_ior"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||1.5===e.ior)return;let n=this.writer.extensionsUsed,r={};r.ior=e.ior,t.extensions=t.extensions||{},t.extensions[this.name]=r,n[this.name]=!0}}class P{constructor(e){this.writer=e,this.name="KHR_materials_specular"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||1===e.specularIntensity&&e.specularColor.equals(u)&&!e.specularIntensityMap&&!e.specularColorMap)return;let n=this.writer,r=n.extensionsUsed,i={};if(e.specularIntensityMap){let t={index:await n.processTextureAsync(e.specularIntensityMap),texCoord:e.specularIntensityMap.channel};n.applyTextureTransform(t,e.specularIntensityMap),i.specularTexture=t}if(e.specularColorMap){let t={index:await n.processTextureAsync(e.specularColorMap),texCoord:e.specularColorMap.channel};n.applyTextureTransform(t,e.specularColorMap),i.specularColorTexture=t}i.specularFactor=e.specularIntensity,i.specularColorFactor=e.specularColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class R{constructor(e){this.writer=e,this.name="KHR_materials_sheen"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||0==e.sheen)return;let n=this.writer,r=n.extensionsUsed,i={};if(e.sheenRoughnessMap){let t={index:await n.processTextureAsync(e.sheenRoughnessMap),texCoord:e.sheenRoughnessMap.channel};n.applyTextureTransform(t,e.sheenRoughnessMap),i.sheenRoughnessTexture=t}if(e.sheenColorMap){let t={index:await n.processTextureAsync(e.sheenColorMap),texCoord:e.sheenColorMap.channel};n.applyTextureTransform(t,e.sheenColorMap),i.sheenColorTexture=t}i.sheenRoughnessFactor=e.sheenRoughness,i.sheenColorFactor=e.sheenColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class S{constructor(e){this.writer=e,this.name="KHR_materials_anisotropy"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||0==e.anisotropy)return;let n=this.writer,r=n.extensionsUsed,i={};if(e.anisotropyMap){let t={index:await n.processTextureAsync(e.anisotropyMap)};n.applyTextureTransform(t,e.anisotropyMap),i.anisotropyTexture=t}i.anisotropyStrength=e.anisotropy,i.anisotropyRotation=e.anisotropyRotation,t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class E{constructor(e){this.writer=e,this.name="KHR_materials_emissive_strength"}async writeMaterialAsync(e,t){if(!e.isMeshStandardMaterial||1===e.emissiveIntensity)return;let n=this.writer.extensionsUsed,r={};r.emissiveStrength=e.emissiveIntensity,t.extensions=t.extensions||{},t.extensions[this.name]=r,n[this.name]=!0}}class O{constructor(e){this.writer=e,this.name="EXT_materials_bump"}async writeMaterialAsync(e,t){if(!e.isMeshStandardMaterial||1===e.bumpScale&&!e.bumpMap)return;let n=this.writer,r=n.extensionsUsed,i={};if(e.bumpMap){let t={index:await n.processTextureAsync(e.bumpMap),texCoord:e.bumpMap.channel};n.applyTextureTransform(t,e.bumpMap),i.bumpTexture=t}i.bumpFactor=e.bumpScale,t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class M{constructor(e){this.writer=e,this.name="EXT_mesh_gpu_instancing"}writeNode(e,t){if(!e.isInstancedMesh)return;let n=this.writer,i=new Float32Array(3*e.count),s=new Float32Array(4*e.count),o=new Float32Array(3*e.count),a=new r.kn4,l=new r.Pq0,c=new r.PTz,u=new r.Pq0;for(let t=0;tMath.abs(e.times[0]-t))return 0;i[0]=t,i.set(e.times,1),s.set(o.evaluate(t),0),s.set(e.values,r),n=0}else if(t>e.times[e.times.length-1]){if(.001>Math.abs(e.times[e.times.length-1]-t))return e.times.length-1;i[i.length-1]=t,i.set(e.times,0),s.set(e.values,0),s.set(o.evaluate(t),e.values.length),n=i.length-1}else for(let a=0;aMath.abs(e.times[a]-t))return a;if(e.times[a]t){i.set(e.times.slice(0,a+1),0),i[a+1]=t,i.set(e.times.slice(a+1),a+2),s.set(e.values.slice(0,(a+1)*r),0),s.set(o.evaluate(t),(a+1)*r),s.set(e.values.slice((a+1)*r),(a+2)*r),n=a+1;break}}return e.times=i,e.values=s,n},mergeMorphTargetTracks:function(e,t){let n=[],i={},s=e.tracks;for(let e=0;e=2.0 are supported."));return}let l=new eT(i,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e=0&&void 0===o[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}l.setExtensions(s),l.setPlugins(o),l.parse(n,r)}parseAsync(e,t){let n=this;return new Promise(function(r,i){n.parse(e,t,r,i)})}}function C(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}let j={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class B{constructor(e){this.parser=e,this.name=j.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n=0))return null;throw Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures")}return t.loadTextureImage(e,i.source,s)}}class Y{constructor(e){this.parser=e,this.name=j.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let s=i.extensions[t],o=r.images[s.source],a=n.textureLoader;if(o.uri){let e=n.options.manager.getHandler(o.uri);null!==e&&(a=e)}return this.detectSupport().then(function(i){if(i)return n.loadTextureImage(e,s.source,a);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){let t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}})),this.isSupported}}class Q{constructor(e){this.parser=e,this.name=j.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let s=i.extensions[t],o=r.images[s.source],a=n.textureLoader;if(o.uri){let e=n.options.manager.getHandler(o.uri);null!==e&&(a=e)}return this.detectSupport().then(function(i){if(i)return n.loadTextureImage(e,s.source,a);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){let t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(1===t.height)}})),this.isSupported}}class J{constructor(e){this.name=j.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(!n.extensions||!n.extensions[this.name])return null;{let e=n.extensions[this.name],r=this.parser.getDependency("buffer",e.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(!(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0))return null;throw Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files")}return r.then(function(t){let n=e.byteOffset||0,r=e.byteLength||0,s=e.count,o=e.byteStride,a=new Uint8Array(t,n,r);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(s,o,a,e.mode,e.filter).then(function(e){return e.buffer}):i.ready.then(function(){let t=new ArrayBuffer(s*o);return i.decodeGltfBuffer(new Uint8Array(t),s,o,a,e.mode,e.filter),t})})}}}class Z{constructor(e){this.name=j.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||void 0===n.mesh)return null;for(let e of t.meshes[n.mesh].primitives)if(e.mode!==el.TRIANGLES&&e.mode!==el.TRIANGLE_STRIP&&e.mode!==el.TRIANGLE_FAN&&void 0!==e.mode)return null;let i=n.extensions[this.name].attributes,s=[],o={};for(let e in i)s.push(this.parser.getDependency("accessor",i[e]).then(t=>(o[e]=t,o[e])));return s.length<1?null:(s.push(this.parser.createNodeMesh(e)),Promise.all(s).then(e=>{let t=e.pop(),n=t.isGroup?t.children:[t],i=e[0].count,s=[];for(let e of n){let t=new r.kn4,n=new r.Pq0,a=new r.PTz,l=new r.Pq0(1,1,1),c=new r.ZLX(e.geometry,e.material,i);for(let e=0;e-1)?e.match(/Firefox\/([0-9]+)\./)[1]:-1}"undefined"==typeof createImageBitmap||n&&i<17||s&&o<98?this.textureLoader=new r.Tap(this.options.manager):this.textureLoader=new r.Kzg(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new r.Y9S(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,r=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(e){return e._markDefs&&e._markDefs()}),Promise.all(this._invokeAll(function(e){return e.beforeRoot&&e.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(t){let s={scene:t[0][r.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:r.asset,parser:n,userData:{}};return ey(i,s,r),eb(s,r),Promise.all(n._invokeAll(function(e){return e.afterRoot&&e.afterRoot(s)})).then(function(){for(let e of s.scenes)e.updateMatrixWorld();e(s)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,r=t.length;n{let n=this.associations.get(e);for(let[r,s]of(null!=n&&this.associations.set(t,n),e.children.entries()))i(s,t.children[r])};return i(n,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n=2&&o.setY(t,f[e*l+1]),l>=3&&o.setZ(t,f[e*l+2]),l>=4&&o.setW(t,f[e*l+3]),l>=5)throw Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}o.normalized=d}return o})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e].source,i=t.images[r],s=this.textureLoader;if(i.uri){let e=n.manager.getHandler(i.uri);null!==e&&(s=e)}return this.loadTextureImage(e,r,s)}loadTextureImage(e,t,n){let i=this,s=this.json,o=s.textures[e],a=s.images[t],l=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[l])return this.textureCache[l];let c=this.loadImageSource(t,n).then(function(t){t.flipY=!1,t.name=o.name||a.name||"",""===t.name&&"string"==typeof a.uri&&!1===a.uri.startsWith("data:image/")&&(t.name=a.uri);let n=(s.samplers||{})[o.sampler]||{};return t.magFilter=eu[n.magFilter]||r.k6q,t.minFilter=eu[n.minFilter]||r.$_I,t.wrapS=eh[n.wrapS]||r.GJx,t.wrapT=eh[n.wrapT]||r.GJx,t.generateMipmaps=!t.isCompressedTexture&&t.minFilter!==r.hxR&&t.minFilter!==r.k6q,i.associations.set(t,{textures:e}),t}).catch(function(){return null});return this.textureCache[l]=c,c}loadImageSource(e,t){let n=this.json,i=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then(e=>e.clone());let s=n.images[e],o=self.URL||self.webkitURL,a=s.uri||"",l=!1;if(void 0!==s.bufferView)a=this.getDependency("bufferView",s.bufferView).then(function(e){l=!0;let t=new Blob([e],{type:s.mimeType});return a=o.createObjectURL(t)});else if(void 0===s.uri)throw Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let c=Promise.resolve(a).then(function(e){return new Promise(function(n,s){let o=n;!0===t.isImageBitmapLoader&&(o=function(e){let t=new r.gPd(e);t.needsUpdate=!0,n(t)}),t.load(r.r6x.resolveURL(e,i.path),o,void 0,s)})}).then(function(e){var t;return!0===l&&o.revokeObjectURL(a),eb(e,s),e.userData.mimeType=s.mimeType||((t=s.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":t.search(/\.ktx2($|\?)/i)>0||0===t.search(/^data\:image\/ktx2/)?"image/ktx2":"image/png"),e}).catch(function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),e});return this.sourceCache[e]=c,c}assignTexture(e,t,n,r){let i=this;return this.getDependency("texture",n.index).then(function(s){if(!s)return null;if(void 0!==n.texCoord&&n.texCoord>0&&((s=s.clone()).channel=n.texCoord),i.extensions[j.KHR_TEXTURE_TRANSFORM]){let e=void 0!==n.extensions?n.extensions[j.KHR_TEXTURE_TRANSFORM]:void 0;if(e){let t=i.associations.get(s);s=i.extensions[j.KHR_TEXTURE_TRANSFORM].extendTexture(s,e),i.associations.set(s,t)}}return void 0!==r&&(s.colorSpace=r),e[t]=s,s})}assignFinalMaterial(e){let t=e.geometry,n=e.material,i=void 0===t.attributes.tangent,s=void 0!==t.attributes.color,o=void 0===t.attributes.normal;if(e.isPoints){let e="PointsMaterial:"+n.uuid,t=this.cache.get(e);t||(t=new r.BH$,r.imn.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){let e="LineBasicMaterial:"+n.uuid,t=this.cache.get(e);t||(t=new r.mrM,r.imn.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,this.cache.add(e,t)),n=t}if(i||s||o){let e="ClonedMaterial:"+n.uuid+":";i&&(e+="derivative-tangents:"),s&&(e+="vertex-colors:"),o&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=n.clone(),s&&(t.vertexColors=!0),o&&(t.flatShading=!0),i&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}e.material=n}getMaterialType(){return r._4j}loadMaterial(e){let t;let n=this,i=this.json,s=this.extensions,o=i.materials[e],a={},l=o.extensions||{},c=[];if(l[j.KHR_MATERIALS_UNLIT]){let e=s[j.KHR_MATERIALS_UNLIT];t=e.getMaterialType(),c.push(e.extendParams(a,o,n))}else{let i=o.pbrMetallicRoughness||{};if(a.color=new r.Q1f(1,1,1),a.opacity=1,Array.isArray(i.baseColorFactor)){let e=i.baseColorFactor;a.color.setRGB(e[0],e[1],e[2],r.Zr2),a.opacity=e[3]}void 0!==i.baseColorTexture&&c.push(n.assignTexture(a,"map",i.baseColorTexture,r.er$)),a.metalness=void 0!==i.metallicFactor?i.metallicFactor:1,a.roughness=void 0!==i.roughnessFactor?i.roughnessFactor:1,void 0!==i.metallicRoughnessTexture&&(c.push(n.assignTexture(a,"metalnessMap",i.metallicRoughnessTexture)),c.push(n.assignTexture(a,"roughnessMap",i.metallicRoughnessTexture))),t=this._invokeOne(function(t){return t.getMaterialType&&t.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,a)})))}!0===o.doubleSided&&(a.side=r.$EB);let u=o.alphaMode||em.OPAQUE;if(u===em.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,u===em.MASK&&(a.alphaTest=void 0!==o.alphaCutoff?o.alphaCutoff:.5)),void 0!==o.normalTexture&&t!==r.V9B&&(c.push(n.assignTexture(a,"normalMap",o.normalTexture)),a.normalScale=new r.I9Y(1,1),void 0!==o.normalTexture.scale)){let e=o.normalTexture.scale;a.normalScale.set(e,e)}if(void 0!==o.occlusionTexture&&t!==r.V9B&&(c.push(n.assignTexture(a,"aoMap",o.occlusionTexture)),void 0!==o.occlusionTexture.strength&&(a.aoMapIntensity=o.occlusionTexture.strength)),void 0!==o.emissiveFactor&&t!==r.V9B){let e=o.emissiveFactor;a.emissive=new r.Q1f().setRGB(e[0],e[1],e[2],r.Zr2)}return void 0!==o.emissiveTexture&&t!==r.V9B&&c.push(n.assignTexture(a,"emissiveMap",o.emissiveTexture,r.er$)),Promise.all(c).then(function(){let r=new t(a);return o.name&&(r.name=o.name),eb(r,o),n.associations.set(r,{materials:e}),o.extensions&&ey(s,r,o),r})}createUniqueName(e){let t=r.Nwf.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,n=this.extensions,i=this.primitiveCache,s=[];for(let o=0,a=e.length;o0&&function(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let n=0,r=t.weights.length;n1?new r.YJl:1===t.length?t[0]:new r.B69)!==t[0])for(let e=0,n=t.length;e{let t=new Map;for(let[e,n]of i.associations)(e instanceof r.imn||e instanceof r.gPd)&&t.set(e,n);return e.traverse(e=>{let n=i.associations.get(e);null!=n&&t.set(e,n)}),t})(s),s})}_createAnimationTracks(e,t,n,i,s){let o;let a=[],l=e.name?e.name:e.uuid,c=[];switch(ed[s.path]===ed.weights?e.traverse(function(e){e.morphTargetInfluences&&c.push(e.name?e.name:e.uuid)}):c.push(l),ed[s.path]){case ed.weights:o=r.Hit;break;case ed.rotation:o=r.MBL;break;case ed.position:case ed.scale:o=r.RiT;break;default:o=1===n.itemSize?r.Hit:r.RiT}let u=void 0!==i.interpolation?ev[i.interpolation]:r.PJ3,h=this._getArrayFromAccessor(n);for(let e=0,n=c.length;e{n.d(t,{m:()=>c});var r=n("./src/model/ball.ts"),i=n("./src/view/tablegeometry.ts"),s=n("./node_modules/three/build/three.module.js"),o=n("./src/utils/utils.ts"),a=n("./src/model/physics/constants.ts");function l(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var c=/*#__PURE__*/function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t)}return e=[{key:"jitter",value:function(e){return(0,o.ld)(e.clone().add(new s.Pq0(t.noise*(Math.random()-.5),t.noise*(Math.random()-.5),0)))}},{key:"cueBall",value:function(e){return new r.c(t.jitter(e),0xfaebd7)}},{key:"diamond",value:function(){var e=new s.Pq0(i.P.tableX/2,0,0),n=[];return n.push(t.cueBall(t.spot)),n.push(new r.c(t.jitter(e),0xe0de36)),e.add(t.diagonal),n.push(new r.c(t.jitter(e),0xff9d00)),e.sub(t.across),n.push(new r.c(t.jitter(e),5380369)),e.add(t.diagonal),n.push(new r.c(t.jitter(e),5853696)),e.sub(t.across),n.push(new r.c(t.jitter(e),0xff0000)),e.addScaledVector(t.across,2),n.push(new r.c(t.jitter(e),328965)),e.add(t.diagonal).sub(t.across),n.push(new r.c(t.jitter(e),685250)),e.sub(t.across),n.push(new r.c(t.jitter(e),553728)),e.add(t.diagonal),n.push(new r.c(t.jitter(e),4063388)),n}},{key:"triangle",value:function(){var e=t.trianglePositions(),n=t.cueBall(t.spot),i=e.map(function(e){return new r.c(t.jitter(e))});return i.unshift(n),i.slice(0,5)}},{key:"trianglePositions",value:function(){var e=[],t=new s.Pq0(i.P.X/2,0,0);return e.push((0,o.t6)(t)),t.add(this.diagonal),e.push((0,o.t6)(t)),t.sub(this.across),e.push((0,o.t6)(t)),t.add(this.diagonal),e.push((0,o.t6)(t)),t.sub(this.across),e.push((0,o.t6)(t)),t.addScaledVector(this.across,2),e.push((0,o.t6)(t)),t.add(this.diagonal),e.push((0,o.t6)(t)),t.sub(this.across),e.push((0,o.t6)(t)),t.sub(this.across),e.push((0,o.t6)(t)),t.sub(this.across),e.push((0,o.t6)(t)),t.add(this.diagonal).sub(this.across),e.push((0,o.t6)(t)),t.add(this.across),e.push((0,o.t6)(t)),t.add(this.across),e.push((0,o.t6)(t)),t.add(this.across),e.push((0,o.t6)(t)),t.add(this.across),e.push((0,o.t6)(t)),e}},{key:"rerack",value:function(e,n){var i=t.trianglePositions(),s=i.shift();n.balls.filter(function(e){return e!==n.cueball}).filter(function(t){return t!==e}).forEach(function(e){e.pos.copy(t.jitter(i.shift())),e.state=r.U.Stationary}),n.overlapsAny(e.pos,e)&&e.pos.copy(s),n.overlapsAny(n.cueball.pos)&&n.cueball.pos.copy(t.spot)}},{key:"three",value:function(){var e=[],n=i.P.X/2,o=i.P.Y/4;return e.push(t.cueBall(t.jitter(new s.Pq0(-n,-o,0)))),e.push(new r.c(t.jitter(new s.Pq0(-n,0,0)),0xe0de36)),e.push(new r.c(t.jitter(new s.Pq0(n,0,0)),0xff0000)),e}},{key:"snooker",value:function(){var e=[],n=i.P.Y/4;e.push(t.cueBall(t.jitter(new s.Pq0(t.baulk,-(.5*n),0))));var o=t.snookerColourPositions();return e.push(new r.c(t.jitter(o[0]),0xeede36)),e.push(new r.c(t.jitter(o[1]),824932)),e.push(new r.c(t.jitter(o[2]),0xbd723a)),e.push(new r.c(t.jitter(o[3]),558062)),e.push(new r.c(t.jitter(o[4]),0xffaacc)),e.push(new r.c(t.jitter(o[5]),65793)),t.trianglePositions().slice(0,15).forEach(function(n){e.push(new r.c(t.jitter(n.add(t.down)),0xee0000))}),e}},{key:"snookerColourPositions",value:function(){var e=i.P.X/2,n=i.P.X-2*i.P.X/11,r=[];return r.push(new s.Pq0(t.baulk,-t.sixth,0)),r.push(new s.Pq0(t.baulk,t.sixth,0)),r.push(new s.Pq0(t.baulk,0,0)),r.push(new s.Pq0(0,0,0)),r.push(new s.Pq0(e,0,0)),r.push(new s.Pq0(n,0,0)),r}}],function(e,t){for(var n=0;n{n.d(t,{k:()=>a});var r=n("./src/model/ball.ts"),i=n("./src/view/tablegeometry.ts"),s=n("./src/model/physics/constants.ts"),o=n("./src/utils/rack.ts"),a=/*#__PURE__*/function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t)}return e=[{key:"respot",value:function(e,n){var i=o.m.snookerColourPositions();return i.push(i[e.id-1]),i.reverse(),i.some(function(t){return!n.overlapsAny(t,e)&&(e.pos.copy(t),e.state=r.U.Stationary,!0)})||t.respotBehind(i[0],e,n),e}},{key:"respotBehind",value:function(e,t,n){for(var o=e.clone();o.x-i.P.tableX&&n.overlapsAny(o,t);)o.x-=s.R/8;t.pos.copy(o),t.state=r.U.Stationary}},{key:"closest",value:function(e,t){var n=t.filter(function(e){return e.onTable()}).filter(function(t){return t!==e});if(0!==n.length){var r=function(t){return e.pos.distanceTo(t.pos)};return n.reduce(function(e,t){return r(e){n.d(t,{Dz:()=>p,KM:()=>l,ld:()=>v,rq:()=>f,t6:()=>o,up:()=>s,v_:()=>i,xb:()=>u});var r=n("./node_modules/three/build/three.module.js"),i=new r.Pq0(0,0,0),s=new r.Pq0(0,0,1);function o(e){return new r.Pq0(e.x,e.y,e.z)}var a=new r.Pq0;function l(e){return a.copy(s).cross(e)}var c=new r.Pq0;function u(e){return c.copy(e).normalize()}var h=new r.Pq0;function f(e,t){return 0>=h.copy(e).add(t).dot(e)}function p(e){return new r.Pq0(1,0,0).applyAxisAngle(s,e)}function d(e){return Math.sign(e)*Math.floor((Math.abs(e)+Number.EPSILON)*1e4)/1e4}function v(e){return e.x=d(e.x),e.y=d(e.y),e.z=d(e.z),e}},"./src/view/assets.ts":(e,t,n)=>{n.d(t,{s:()=>m});var r=n("./src/controller/rules/rulefactory.ts"),i=n("./src/utils/gltf.ts"),s=n("./node_modules/three/build/three.module.js");function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var a=/*#__PURE__*/function(){var e;function t(e){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),o(this,"listener",void 0),o(this,"audioLoader",void 0),o(this,"ballcollision",void 0),o(this,"cue",void 0),o(this,"cushion",void 0),o(this,"pot",void 0),o(this,"success",void 0),o(this,"lastOutcomeTime",0),o(this,"loadAssets",void 0),this.loadAssets=e,e&&(this.listener=new s.Pf$,this.audioLoader=new s.Am1,this.ballcollision=new s.fP5(this.listener),this.load("sounds/ballcollision.ogg",this.ballcollision),this.cue=new s.fP5(this.listener),this.load("sounds/cue.ogg",this.cue),this.cushion=new s.fP5(this.listener),this.load("sounds/cushion.ogg",this.cushion),this.pot=new s.fP5(this.listener),this.load("sounds/pot.ogg",this.pot),this.success=new s.fP5(this.listener),this.load("sounds/success.ogg",this.success))}return e=[{key:"addCameraToListener",value:function(e){e.add(this.listener)}},{key:"load",value:function(e,t){this.audioLoader.load(e,function(e){t.setBuffer(e),t.setLoop(!1)},function(e){},function(e){})}},{key:"play",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(this.loadAssets){var r,i,o=s.UtX.getContext();if((null==o?void 0:o.state)==="suspended"){(null===(i=navigator)||void 0===i?void 0:null===(r=i.userActivation)||void 0===r?void 0:r.hasBeenActive)&&o.resume();return}e.setVolume(t),e.isPlaying&&e.stop(),e.play(s.cj9.randFloat(0,.01)),e.setDetune(n)}}},{key:"outcomeToSound",value:function(e){"Collision"===e.type&&this.play(this.ballcollision,e.incidentSpeed/80,5*e.incidentSpeed),"Pot"===e.type&&this.play(this.pot,e.incidentSpeed/10,-1e3+10*e.incidentSpeed),"Cushion"===e.type&&this.play(this.cushion,e.incidentSpeed/70),"Hit"===e.type&&this.play(this.cue,e.incidentSpeed/30)}},{key:"processOutcomes",value:function(e){var t=this;e.every(function(e){return!(e.timestamp>t.lastOutcomeTime)||(t.lastOutcomeTime=e.timestamp,t.outcomeToSound(e),!1)})}},{key:"playNotify",value:function(){this.play(this.pot,1)}},{key:"playSuccess",value:function(e){this.play(this.success,.1,100*e-2200)}}],function(e,t){for(var n=0;n2&&void 0!==arguments[2]?arguments[2]:this.cloth;this.cylinder(e.pos,e.radius,.75*u.R/.5,t,n).position.setZ(-(.25*u.R)/.5/2)}},{key:"cylinder",value:function(e,t,n,r,i){var o=new s.Ho_(t,t,n,16),a=new s.eaF(o,i);return a.position.copy(e),a.geometry.applyMatrix4(new s.kn4().identity().makeRotationAxis(new s.Pq0(1,0,0),Math.PI/2)),r.add(a),a}},{key:"addCushions",value:function(e,t){var n=10*u.R/.5;this.plane(new s.Pq0(0,0,-u.R-n/2),2*l.P.X,2*l.P.Y,n,e,this.cloth);var r=1*u.R/.5,i=.75*u.R/.5,o=-(.25*u.R)/.5/2,a=l.P.X,h=l.P.Y,f=Math.abs(c.f.pockets.pocketNW.knuckleNE.pos.x-c.f.pockets.pocketN.knuckleNW.pos.x),p=Math.abs(c.f.pockets.pocketNW.knuckleSW.pos.y-c.f.pockets.pocketSW.knuckleNW.pos.y);t||(f=2*l.P.Y,p=2*l.P.Y+4*u.R),this.plane(new s.Pq0(a+r/2,0,o),r,p,i,e),this.plane(new s.Pq0(-a-r/2,0,o),r,p,i,e),this.plane(new s.Pq0(-a/2,h+r/2,o),f,r,i,e),this.plane(new s.Pq0(-a/2,-h-r/2,o),f,r,i,e),this.plane(new s.Pq0(a/2,h+r/2,o),f,r,i,e),this.plane(new s.Pq0(a/2,-h-r/2,o),f,r,i,e)}},{key:"plane",value:function(e,t,n,r,i){var o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:this.cushion,a=new s.iNn(t,n,r),l=new s.eaF(a,o);l.receiveShadow=!0,l.position.copy(e),i.add(l)}}],function(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:"",t=new n(e);return t.creatLocal(),t}}],e&&d(n.prototype,e),t&&d(n,t),n}()},"./src/view/cameratop.ts":(e,t,n)=>{n.d(t,{v:()=>a});var r=n("./node_modules/three/build/three.module.js"),i=n("./src/view/tablegeometry.ts"),s=n("./src/model/physics/constants.ts");function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var a=/*#__PURE__*/function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t)}return e=[{key:"viewPoint",value:function(e,n){var o=t.zoomFactor/(2*Math.tan(n*Math.PI/360));if(e>this.portrait){var a=e>t.aspectLimit?2.75*i.P.tableY:2.4*i.P.tableX/e;return new r.Pq0(0,-.01*s.R,o*a)}var l=e>1/t.aspectLimit?4.9*i.P.tableY:1.35*i.P.tableX/e;return new r.Pq0(-.01*s.R,0,o*l)}}],function(e,t){for(var n=0;n{n.d(t,{s:()=>f});var r=n("./src/view/tablegeometry.ts"),i=n("./src/utils/utils.ts"),s=n("./src/events/aimevent.ts"),o=n("./src/model/ball.ts"),a=n("./src/model/physics/physics.ts"),l=n("./src/view/cuemesh.ts"),c=n("./node_modules/three/build/three.module.js"),u=n("./src/model/physics/constants.ts");function h(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var f=/*#__PURE__*/function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),h(this,"mesh",void 0),h(this,"helperMesh",void 0),h(this,"placerMesh",void 0),h(this,"offCenterLimit",.3),h(this,"maxPower",150*u.R),h(this,"t",0),h(this,"aimInputs",void 0),h(this,"aim",new s.w),h(this,"length",1*r.P.tableX),this.mesh=l.l.createCue(.05*u.R/.5,.15*u.R/.5,this.length),this.helperMesh=l.l.createHelper(),this.placerMesh=l.l.createPlacer()}return e=[{key:"rotateAim",value:function(e,t){this.aim.angle=this.aim.angle+e,this.mesh.rotation.z=this.aim.angle,this.helperMesh.rotation.z=this.aim.angle,this.aimInputs.showOverlap(),this.avoidCueTouchingOtherBall(t)}},{key:"adjustPower",value:function(e){this.aim.power=Math.min(this.maxPower,this.aim.power+e),this.updateAimInput()}},{key:"setPower",value:function(e){this.aim.power=e*this.maxPower}},{key:"hit",value:function(e){var t=this.aim;this.t=0,e.state=o.U.Sliding,e.vel.copy((0,i.Dz)(t.angle).multiplyScalar(t.power)),e.rvel.copy((0,a.t6)(t.offset,e.vel))}},{key:"aimAtNext",value:function(e,t){if(t){var n=(0,i.xb)(t.pos.clone().sub(e.pos));this.aim.angle=Math.atan2(n.y,n.x)}}},{key:"adjustSpin",value:function(e,t){var n=this.aim.offset.clone().clone().add(e);this.setSpin(n,t)}},{key:"setSpin",value:function(e,t){e.length()>this.offCenterLimit&&e.normalize().multiplyScalar(this.offCenterLimit),this.aim.offset.copy(e),this.avoidCueTouchingOtherBall(t),this.updateAimInput()}},{key:"avoidCueTouchingOtherBall",value:function(e){for(var t=0;t++<20&&this.intersectsAnything(e);)this.aim.offset.y+=.1,this.aim.offset.length()>this.offCenterLimit&&this.aim.offset.normalize().multiplyScalar(this.offCenterLimit);t>1&&this.updateAimInput()}},{key:"updateAimInput",value:function(){var e,t,n;null===(e=this.aimInputs)||void 0===e||e.updateVisualState(this.aim.offset.x,this.aim.offset.y),null===(t=this.aimInputs)||void 0===t||t.updatePowerSlider(this.aim.power/this.maxPower),null===(n=this.aimInputs)||void 0===n||n.showOverlap()}},{key:"moveTo",value:function(e){this.aim.pos.copy(e),this.mesh.rotation.z=this.aim.angle,this.helperMesh.rotation.z=this.aim.angle;var t=this.spinOffset(),n=(Math.sin(this.t+Math.PI/2)-1)*2*u.R*(this.aim.power/this.maxPower),r=(0,i.Dz)(this.aim.angle).clone().multiplyScalar(n);this.mesh.position.copy(e.clone().add(t).add(r)),this.helperMesh.position.copy(e),this.placerMesh.position.copy(e),this.placerMesh.rotation.z=this.t}},{key:"update",value:function(e){this.t+=e,this.moveTo(this.aim.pos)}},{key:"placeBallMode",value:function(){this.mesh.visible=!1,this.placerMesh.visible=!0,this.aim.angle=0}},{key:"aimMode",value:function(){this.mesh.visible=!0,this.placerMesh.visible=!1}},{key:"spinOffset",value:function(){return(0,i.KM)((0,i.Dz)(this.aim.angle)).multiplyScalar(2*this.aim.offset.x*u.R).setZ(2*this.aim.offset.y*u.R)}},{key:"intersectsAnything",value:function(e){var t=this.spinOffset(),n=e.cueball.pos.clone().add(t),r=(0,i.xb)((0,i.Dz)(this.aim.angle+Math.PI).setZ(.1)),s=new c.tBo(n,r),o=e.balls.map(function(e){return e.ballmesh.mesh});return e.mesh&&o.push(e.mesh),s.intersectObjects(o,!0).length>0}},{key:"showHelper",value:function(e){this.helperMesh.visible=e}},{key:"toggleHelper",value:function(){this.showHelper(!this.helperMesh.visible)}}],function(e,t){for(var n=0;n{n.d(t,{l:()=>a});var r=n("./src/model/physics/constants.ts"),i=n("./src/utils/utils.ts"),s=n("./node_modules/three/build/three.module.js");function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var a=/*#__PURE__*/function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t)}return e=[{key:"indicateValid",value:function(e){t.placermaterial.color.setHex(e?0xccffcc:0xff0000)}},{key:"createHelper",value:function(){var e=new s.Ho_(r.R,r.R,30*r.R/.5,12,1,!0),t=new s.eaF(e,this.helpermaterial);return t.geometry.applyMatrix4(new s.kn4().identity().makeRotationAxis(i.up,-Math.PI/2)).applyMatrix4(new s.kn4().identity().makeTranslation(15*r.R/.5,0,-(.01*r.R)/.5)),t.visible=!1,t.renderOrder=-1,t.material.depthTest=!1,t}},{key:"createPlacer",value:function(){var e=new s.Ho_(.01*r.R/.5,r.R,r.R,4),n=new s.eaF(e,t.placermaterial);return n.geometry.applyMatrix4(new s.kn4().identity().makeRotationAxis(new s.Pq0(1,0,0),-Math.PI/2)).applyMatrix4(new s.kn4().identity().makeTranslation(0,0,.7*r.R/.5)),n.visible=!1,n}},{key:"createCue",value:function(e,n,o){var a=new s.Ho_(e,n,o,11),l=new s.eaF(a,t.material);return l.castShadow=!1,l.geometry.applyMatrix4(new s.kn4().identity().makeRotationAxis(new s.Pq0(1,0,0),-.17)).applyMatrix4(new s.kn4().identity().makeRotationAxis(i.up,-Math.PI/2)).applyMatrix4(new s.kn4().identity().makeTranslation(-o/2-r.R,0,o/2*.16918234906699603+.25*r.R)),l}}],function(e,t){for(var n=0;n{n.d(t,{f:()=>c});var r=n("./node_modules/three/build/three.module.js"),i=n("./src/model/physics/knuckle.ts"),s=n("./src/model/physics/pocket.ts"),o=n("./src/view/tablegeometry.ts"),a=n("./src/model/physics/constants.ts");function l(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var c=/*#__PURE__*/function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t)}return e=[{key:"scaleToRadius",value:function(e){t.PX=o.P.tableX+1.6*e,t.PY=o.P.tableY+1.6*e,t.knuckleInset=1.6*e/.5,t.knuckleRadius=.31*e/.5,t.middleKnuckleInset=1.385*e/.5,t.middleKnuckleRadius=.2*e/.5,t.cornerRadius=1.1*e/.5,t.middleRadius=.9*e/.5,t.pocketLayout(e),t.enumerateCenters(),t.enumerateKnuckles()}},{key:"enumerateKnuckles",value:function(){t.knuckles=[t.pockets.pocketNW.knuckleNE,t.pockets.pocketNW.knuckleSW,t.pockets.pocketN.knuckleNW,t.pockets.pocketN.knuckleNE,t.pockets.pocketS.knuckleSW,t.pockets.pocketS.knuckleSE,t.pockets.pocketNE.knuckleNW,t.pockets.pocketNE.knuckleSE,t.pockets.pocketSE.knuckleNE,t.pockets.pocketSE.knuckleSW,t.pockets.pocketSW.knuckleSE,t.pockets.pocketSW.knuckleNW]}},{key:"enumerateCenters",value:function(){t.pocketCenters=[t.pockets.pocketNW.pocket,t.pockets.pocketSW.pocket,t.pockets.pocketN.pocket,t.pockets.pocketS.pocket,t.pockets.pocketNE.pocket,t.pockets.pocketSE.pocket]}},{key:"pocketLayout",value:function(e){t.pockets={pocketNW:{pocket:new s.Z(new r.Pq0(-t.PX,t.PY,0),t.cornerRadius),knuckleNE:new i.O(new r.Pq0(-o.P.X+t.knuckleInset,o.P.Y+t.knuckleRadius,0),t.knuckleRadius),knuckleSW:new i.O(new r.Pq0(-o.P.X-t.knuckleRadius,o.P.Y-t.knuckleInset,0),t.knuckleRadius)},pocketN:{pocket:new s.Z(new r.Pq0(0,t.PY+.7*e/.5,0),t.middleRadius),knuckleNE:new i.O(new r.Pq0(t.middleKnuckleInset,o.P.Y+t.middleKnuckleRadius,0),t.middleKnuckleRadius),knuckleNW:new i.O(new r.Pq0(-t.middleKnuckleInset,o.P.Y+t.middleKnuckleRadius,0),t.middleKnuckleRadius)},pocketS:{pocket:new s.Z(new r.Pq0(0,-t.PY-.7*e/.5,0),t.middleRadius),knuckleSE:new i.O(new r.Pq0(t.middleKnuckleInset,-o.P.Y-t.middleKnuckleRadius,0),t.middleKnuckleRadius),knuckleSW:new i.O(new r.Pq0(-t.middleKnuckleInset,-o.P.Y-t.middleKnuckleRadius,0),t.middleKnuckleRadius)},pocketNE:{pocket:new s.Z(new r.Pq0(t.PX,t.PY,0),t.cornerRadius),knuckleNW:new i.O(new r.Pq0(o.P.X-t.knuckleInset,o.P.Y+t.knuckleRadius,0),t.knuckleRadius),knuckleSE:new i.O(new r.Pq0(o.P.X+t.knuckleRadius,o.P.Y-t.knuckleInset,0),t.knuckleRadius)},pocketSE:{pocket:new s.Z(new r.Pq0(t.PX,-t.PY,0),t.cornerRadius),knuckleNE:new i.O(new r.Pq0(o.P.X+t.knuckleRadius,-o.P.Y+t.knuckleInset,0),t.knuckleRadius),knuckleSW:new i.O(new r.Pq0(o.P.X-t.knuckleInset,-o.P.Y-t.knuckleRadius,0),t.knuckleRadius)},pocketSW:{pocket:new s.Z(new r.Pq0(-t.PX,-t.PY,0),t.cornerRadius),knuckleSE:new i.O(new r.Pq0(-o.P.X+t.knuckleInset,-o.P.Y-t.knuckleRadius,0),t.knuckleRadius),knuckleNW:new i.O(new r.Pq0(-o.P.X-t.knuckleRadius,-o.P.Y+t.knuckleInset,0),t.knuckleRadius)}}}}],function(e,t){for(var n=0;n{n.d(t,{r:()=>s});var r=n("./src/model/physics/constants.ts");function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var s=/*#__PURE__*/function(){var e;function t(e){var n,s;!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),i(this,"style",void 0),i(this,"notify",void 0),this.notify=null!=e?e:function(){},this.style=null!==(s=null===(n=document.getElementById("constants"))||void 0===n?void 0:n.style)&&void 0!==s?s:{},this.initialiseSlider("R",r.R,r.jG),this.initialiseSlider("m",r.m,r.Qg),this.initialiseSlider("e",r.e,r.cM),this.initialiseSlider("mu",r.mu,r.xO),this.initialiseSlider("muS",r.gf,r.Ys),this.initialiseSlider("muC",r.gT,r.kM),this.initialiseSlider("rho",r.kL,r.Wv)}return e=[{key:"toggleVisibility",value:function(){this.style.visibility="visible"===this.style.visibility?"hidden":"visible"}},{key:"getInputElement",value:function(e){var t;return null!==(t=document.getElementById(e))&&void 0!==t?t:{}}},{key:"initialiseSlider",value:function(e,t,n){var r=this,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,s=this.getInputElement(e);s.step="0.001",s.min="0.01",s.max="".concat(i),s.value=t,this.showValue(e,t),s.oninput=function(t){var i=parseFloat(t.target.value);n(i),r.showValue(e,i),r.notify()}}},{key:"showValue",value:function(e,t){var n=document.querySelector("label[for=".concat(e,"]"));n&&(n.innerHTML="".concat(e,"=").concat(t))}}],function(e,t){for(var n=0;n{n.d(t,{P:()=>s});var r=n("./src/model/physics/constants.ts");function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var s=/*#__PURE__*/function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t)}return e=[{key:"scaleToRadius",value:function(e){t.tableX=43*e,t.tableY=21*e,t.X=t.tableX+e,t.Y=t.tableY+e}}],function(e,t){for(var n=0;n{e(e.s="./src/index.ts")}]); \ No newline at end of file +"use strict";(self.webpackChunkbilliards=self.webpackChunkbilliards||[]).push([[57],{"./src/container/container.ts":(e,t,n)=>{n.d(t,{m:()=>Z});var r=n("./src/events/stationaryevent.ts"),i=n("./node_modules/three/build/three.module.js"),s=n("./src/utils/utils.ts"),o=n("./src/view/cameratop.ts"),a=n("./src/model/physics/constants.ts");function l(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var c=/*#__PURE__*/function(){var e;function t(e){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),l(this,"camera",void 0),l(this,"mode",this.topView),l(this,"mainMode",this.aimView),l(this,"height",8*a.R),l(this,"elapsed",void 0),this.camera=new i.ubm(45,e,a.R,1e3*a.R)}return e=[{key:"update",value:function(e,t){this.elapsed=e,this.mode(t)}},{key:"topView",value:function(e){this.camera.fov=o.v.fov,this.camera.position.lerp(o.v.viewPoint(this.camera.aspect,this.camera.fov),.9),this.camera.up=s.up,this.camera.lookAt(s.v_)}},{key:"aimView",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.08,n=this.height,r=this.camera.aspect<.8;if(this.camera.fov=r?60:40,n<10*a.R){var i=100*(10*a.R-n);this.camera.fov-=i*(r?3:1)}this.camera.position.lerp(e.pos.clone().addScaledVector((0,s.Dz)(e.angle),-(18*a.R)),t),this.camera.position.z=n,this.camera.up=s.up,this.camera.lookAt(e.pos.clone().addScaledVector(s.up,n/2))}},{key:"adjustHeight",value:function(e){e=this.height<10*a.R?e/8:e,this.height=i.cj9.clamp(this.height+e,6*a.R,120*a.R),this.height>110*a.R&&this.suggestMode(this.topView),this.height<105*a.R&&this.suggestMode(this.aimView)}},{key:"suggestMode",value:function(e){this.mainMode===this.aimView&&(this.mode=e)}},{key:"forceMode",value:function(e){this.mode=e,this.mainMode=e}},{key:"forceMove",value:function(e){this.mode===this.aimView&&this.aimView(e,1)}},{key:"toggleMode",value:function(){this.mode===this.topView?this.mode=this.aimView:this.mode=this.topView,this.mainMode=this.mode}}],function(e,t){for(var n=0;n0&&(null===(t=this.cuePowerElement)||void 0===t?void 0:t.value)&&(this.cuePowerElement.value=e)}}],function(e,t){for(var n=0;nthis.sentTime+this.period||e.type!==L.B.AIM){this.flush(),this.apply(e),this.sentTime=performance.now();return}this.pending=e}}],function(e,t){for(var n=0;n0&&"RERACK"===this.shots[e].type&&e--,e}},{key:"lastShot",value:function(){var e=this.last();return this.state(this.states[e],[this.shots[e]])}},{key:"currentBreak",value:function(){if(void 0!==this.breakStart)return this.state(this.states[this.breakStart],this.shots.slice(this.breakStart),this.breakStartTime,this.container.rules.previousBreak)}},{key:"state",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];return{init:e,shots:t,start:n,now:Date.now(),score:r,wholeGame:i}}},{key:"updateBreak",value:function(e){var t=this.container.rules.isPartOfBreak(e),n=this.container.rules.isEndOfGame(e),r=D.P.potCount(e);if(t||this.breakLink(n),this.lastShotLink(t||n,r,D.P.pots(e)),n&&this.breakLink(n),!t){this.breakStart=void 0;return}void 0===this.breakStart&&(this.breakStart=this.last(),this.breakStartTime=Date.now())}},{key:"lastShotLink",value:function(e,t,n){var r="#000000";n.length>0&&n.forEach(function(e){r="#"+e.ballmesh.color.getHexString()});var i="⚈".repeat(t>1?t-1:0)+(e?"⚈":"⚆"),s=JSON.stringify(this.lastShot());this.generateLink(i,s,r)}},{key:"breakLink",value:function(e){var t=this.currentBreak();if(t&&(e||t.shots.pop(),1!==t.shots.length)){var n=0===this.container.rules.currentBreak?this.container.rules.previousBreak:this.container.rules.currentBreak;t.score=n;var r=JSON.stringify(t),i=z.A.crush(r);this.generateLink("break(".concat(n,")"),i,"black"),n>=4&&this.generateHiScoreLink(i)}}},{key:"wholeGameLink",value:function(){var e=this.wholeGame(),t="frame(".concat(this.shotCount(e.shots)," shots)"),n=JSON.stringify(e),r=z.A.crush(n);this.generateLink(t,r,"black")}},{key:"shotCount",value:function(e){return e.filter(function(e){return"RERACK"!==e.type}).length}},{key:"generateLink",value:function(e,t,n){var r="".concat(this.replayUrl).concat(this.fullyEncodeURI(t)),i='').concat(e,"");this.container.eventQueue.push(new N.b(null,"".concat(i)))}},{key:"generateHiScoreLink",value:function(e){var t="".concat(this.hiScoreUrl,"?ruletype=").concat(this.container.rules.rulename,"&state=").concat(this.fullyEncodeURI(e)),n='').concat("hi score 🏆","");this.container.eventQueue.push(new N.b(null,"".concat(n)))}},{key:"fullyEncodeURI",value:function(e){return encodeURIComponent(e).replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/\!/g,"%21").replace(/\*/g,"%2A")}}],function(e,t){for(var n=0;n').concat(e,"")));r.push(new N.b(null,o))})},this.redo.onclick=function(e){var r=new X.W(t.init,t.shots);r.retry=!0,n.interuptEventQueue(r)},this.replay.onclick=function(e){n.interuptEventQueue(t)}}}},{key:"interuptEventQueue",value:function(e){this.container.table.halt();var t=this.container.eventQueue;t.length=0,t.push(new r.T),t.push(e)}},{key:"getElement",value:function(e){return document.getElementById(e)}}],function(e,t){for(var n=0;n0?this.element.innerHTML="Break
"+e:this.element.innerHTML="")}},{key:"getElement",value:function(e){return document.getElementById(e)}}],function(e,t){for(var n=0;n0;){this.lastEventTime=this.last;var t=this.inputQueue.shift();t&&this.updateController(this.controller.handleInput(t))}if(this.table.allStationary()){var n=this.eventQueue.shift();n&&(this.lastEventTime=performance.now(),this.updateController(n.applyToController(this.controller)))}}},{key:"animate",value:function(e){var t=this;this.advance((e-this.last)/1e3),this.last=e,this.processEvents(),(e{n.d(t,{m:()=>u});var r=n("./src/controller/controller.ts"),i=n("./src/controller/controllerbase.ts"),s=n("./src/controller/playshot.ts"),o=n("./src/controller/replay.ts");function a(e){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function l(e,t){return(l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(c=function(){return!!e})()}var u=/*#__PURE__*/function(e){var t;function n(e){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,n),r=n,i=[e],r=a(r);var t,r,i,s,o=(s=(t=c()?Reflect.construct(r,i||[],a(this).constructor):r.apply(this,i))&&("object"==(t&&"undefined"!=typeof Symbol&&t.constructor===Symbol?"symbol":typeof t)||"function"==typeof t)?t:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this)).container.table;return o.cue.aimMode(),o.cue.showHelper(!0),o.cueball=s.container.rules.cueball,o.cue.moveTo(o.cueball.pos),s.container.view.camera.suggestMode(s.container.view.camera.aimView),o.cue.aimInputs.showOverlap(),s}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&l(e,t)}(n,e),t=[{key:"handleInput",value:function(e){switch(e.key){case"Space":this.container.table.cue.adjustPower(e.t*this.scale*.7);break;case"SpaceUp":return this.playShot();default:if(!this.commonKeyHandler(e))return this}return this.container.sendEvent(this.container.table.cue.aim),this}},{key:"handleBreak",value:function(e){return new o.e(this.container,e.init,e.shots,e.retry)}},{key:"playShot",value:function(){var e=new r.Qe(this.container.table.serialise());return this.container.sendEvent(e),this.container.recorder.record(e),new s.H(this.container)}}],function(e,t){for(var n=0;n{n.d(t,{Qe:()=>r.Q,pd:()=>i.p,xI:()=>s}),n("./src/events/beginevent.ts"),n("./src/events/aimevent.ts");var r=n("./src/events/hitevent.ts"),i=n("./src/events/input.ts");n("./src/events/abortevent.ts"),n("./src/events/stationaryevent.ts");var s=/*#__PURE__*/function(){var e;function t(e){var n,r;!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),r=void 0,(n="container")in this?Object.defineProperty(this,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):this[n]=r,this.container=e}return e=[{key:"handleInput",value:function(e){return this}},{key:"handleBegin",value:function(e){return this}},{key:"handleBreak",value:function(e){return this}},{key:"handleStartAim",value:function(e){return this}},{key:"handleAim",value:function(e){return this}},{key:"handleHit",value:function(e){return this}},{key:"handleAbort",value:function(e){return this}},{key:"handleWatch",value:function(e){return this}},{key:"handlePlaceBall",value:function(e){return this}},{key:"handleStationary",value:function(e){return this}},{key:"handleChat",value:function(e){return this}},{key:"handleRejoin",value:function(e){return this}},{key:"onFirst",value:function(){}}],function(e,t){for(var n=0;n{n.d(t,{y:()=>f});var r=n("./src/controller/controller.ts"),i=n("./src/controller/end.ts"),s=n("./src/utils/gltf.ts"),o=n("./src/model/outcome.ts"),a=n("./node_modules/three/build/three.module.js");function l(e){return(l=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function u(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function h(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(h=function(){return!!e})()}var f=/*#__PURE__*/function(e){var t;function n(){var e,t,r,i,s;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,n),t=n,r=arguments,t=l(t),(i="scale")in(e=(s=h()?Reflect.construct(t,r||[],l(this).constructor):t.apply(this,r))&&("object"===u(s)||"function"==typeof s)?s:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this))?Object.defineProperty(e,i,{value:.001,enumerable:!0,configurable:!0,writable:!0}):e[i]=.001,e}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c(e,t)}(n,e),t=[{key:"handleAbort",value:function(e){return new i.o(this.container)}},{key:"handleChat",value:function(e){var t=e.sender?"".concat(e.sender,":"):"",n="".concat(t," ").concat(e.message);return this.container.chat.showMessage(n),this}},{key:"hit",value:function(){this.container.table.outcome=[o.P.hit(this.container.table.cueball,this.container.table.cue.aim.power)],this.container.table.hit(),this.container.view.camera.suggestMode(this.container.view.camera.aimView),this.container.table.cue.showHelper(!1)}},{key:"commonKeyHandler",value:function(e){var t=this.container.table.cue,n=e.t*this.scale;switch(e.key){case"ArrowLeft":return t.rotateAim(-n,this.container.table),!0;case"ArrowRight":return t.rotateAim(n,this.container.table),!0;case"ArrowDown":return t.adjustSpin(new a.Pq0(0,-n),this.container.table),!0;case"ArrowUp":return t.adjustSpin(new a.Pq0(0,n),this.container.table),!0;case"ShiftArrowLeft":return t.adjustSpin(new a.Pq0(n,0),this.container.table),!0;case"ShiftArrowRight":return t.adjustSpin(new a.Pq0(-n,0),this.container.table),!0;case"KeyPUp":return(0,s.KP)(this.container.view.scene),!0;case"KeyHUp":return t.toggleHelper(),!0;case"movementXUp":return t.rotateAim(2*n,this.container.table),!0;case"movementYUp":case"NumpadSubtract":return this.container.view.camera.adjustHeight(8*n),!0;case"NumpadAdd":return this.container.view.camera.adjustHeight(-(8*n)),!0;case"KeyOUp":return this.container.view.camera.toggleMode(),!0;case"KeyDUp":return this.togglePanel(),!0;case"KeyFUp":return this.toggleFullscreen(),!0;default:return!1}}},{key:"togglePanel",value:function(){this.container.sliders.toggleVisibility(),this.container.table.showSpin(!0),this.container.table.showTraces(!0),("undefined"==typeof process?"undefined":u(process))!=="object"&&console.log(this.container.table.serialise())}},{key:"toggleFullscreen",value:function(){document.fullscreenElement?document.exitFullscreen&&document.exitFullscreen():document.documentElement.requestFullscreen()}}],function(e,t){for(var n=0;n{function r(e){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function i(e,t){return(i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function s(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(s=function(){return!!e})()}n.d(t,{o:()=>o});var o=/*#__PURE__*/function(e){var t;function n(){var e,t,i;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,n),e=n,t=arguments,e=r(e),(i=s()?Reflect.construct(e,t||[],r(this).constructor):e.apply(this,t))&&("object"==(i&&"undefined"!=typeof Symbol&&i.constructor===Symbol?"symbol":typeof i)||"function"==typeof i)?i:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this)}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&i(e,t)}(n,e),t=[{key:"handleChat",value:function(e){var t=e.sender?"".concat(e.sender,":"):"",n="".concat(t," ").concat(e.message);return this.container.chat.showMessage(n),this}}],function(e,t){for(var n=0;n{n.d(t,{x:()=>p});var r=n("./src/controller/controllerbase.ts"),i=n("./src/controller/controller.ts"),s=n("./src/controller/aim.ts"),o=n("./src/events/breakevent.ts"),a=n("./src/model/physics/constants.ts"),l=n("./node_modules/three/build/three.module.js"),c=n("./src/view/cuemesh.ts");function u(e){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function h(e,t){return(h=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function f(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(f=function(){return!!e})()}var p=/*#__PURE__*/function(e){var t;function n(e){var t,r,i,s,o,l,c;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,n),r=n,i=[e],r=u(r),s=t=(c=f()?Reflect.construct(r,i||[],u(this).constructor):r.apply(this,i))&&("object"==(c&&"undefined"!=typeof Symbol&&c.constructor===Symbol?"symbol":typeof c)||"function"==typeof c)?c:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this),o="placescale",l=.02*a.R,o in s?Object.defineProperty(s,o,{value:l,enumerable:!0,configurable:!0,writable:!0}):s[o]=l,t.container.table.cue.moveTo(t.container.table.cueball.pos),t.container.table.cue.aim.power=0,t.container.view.camera.forceMode(t.container.view.camera.aimView),t}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&h(e,t)}(n,e),t=[{key:"onFirst",value:function(){var e=this.container.table.cueball;this.container.rules.allowsPlaceBall()&&e.pos.copy(this.container.rules.placeBall()),e.setStationary(),e.updateMesh(0),this.container.table.cue.placeBallMode(),this.container.table.cue.showHelper(!1),this.container.table.cue.moveTo(this.container.table.cueball.pos),this.container.table.cue.aimInputs.setButtonText("Place\nBall"),this.container.rules.allowsPlaceBall()||this.container.inputQueue.push(new i.pd(1,"SpaceUp"))}},{key:"handleInput",value:function(e){var t=this.container.table.cueball.pos;switch(e.key){case"ArrowLeft":case"KeyI":this.moveTo(0,e.t*this.placescale);break;case"ArrowRight":case"KeyK":this.moveTo(0,-e.t*this.placescale);break;case"movementXUp":this.moveTo(0,-e.t*this.placescale*2);break;case"movementYUp":this.moveTo(-e.t*this.placescale*2,0);break;case"KeyJ":this.moveTo(-e.t*this.placescale,0);break;case"KeyL":this.moveTo(e.t*this.placescale,0);break;case"SpaceUp":return this.placed();default:this.commonKeyHandler(e)}return this.container.table.cue.moveTo(t),this.container.view.camera.forceMove(this.container.table.cue.aim),this.container.sendEvent(this.container.table.cue.aim),this}},{key:"moveTo",value:function(e,t){var n=new l.Pq0(e,t),r=this.container.table.cueball.pos.add(n);r.copy(this.container.rules.placeBall(r)),c.l.indicateValid(!this.container.table.overlapsAny(r))}},{key:"placed",value:function(){return this.container.table.overlapsAny(this.container.table.cueball.pos)?this:(this.container.table.cue.aimInputs.setButtonText("Hit"),this.container.sound.playNotify(),this.container.sendEvent(new o.W(this.container.table.shortSerialise())),new s.m(this.container))}}],function(e,t){for(var n=0;n{function r(e){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function i(e,t){return(i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function s(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(s=function(){return!!e})()}n.d(t,{H:()=>o});var o=/*#__PURE__*/function(e){var t;function n(e){var t,i,o,a;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,n),i=n,o=[e],i=r(i),(t=(a=s()?Reflect.construct(i,o||[],r(this).constructor):i.apply(this,o))&&("object"==(a&&"undefined"!=typeof Symbol&&a.constructor===Symbol?"symbol":typeof a)||"function"==typeof a)?a:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this)).hit(),t}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&i(e,t)}(n,e),t=[{key:"handleStationary",value:function(e){var t=this.container.table,n=t.outcome,r=this.container.rules.update(n);return this.container.recorder.updateBreak(n),t.cue.aimAtNext(t.cueball,this.container.rules.nextCandidateBall()),r}},{key:"handleInput",value:function(e){return this.commonKeyHandler(e),this}}],function(e,t){for(var n=0;n{n.d(t,{e:()=>m});var r=n("./src/events/hitevent.ts"),i=n("./src/controller/controllerbase.ts"),s=n("./src/events/aimevent.ts"),o=n("./src/events/breakevent.ts"),a=n("./src/controller/aim.ts"),l=n("./src/events/eventtype.ts"),c=n("./src/events/rerackevent.ts");function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n3&&void 0!==arguments[3]&&arguments[3],u=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1500;if(!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,n),s=n,a=[e],s=f(s),h(l=(i=v()?Reflect.construct(s,a||[],f(this).constructor):s.apply(this,a))&&("object"==(i&&"undefined"!=typeof Symbol&&i.constructor===Symbol?"symbol":typeof i)||"function"==typeof i)?i:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this),"delay",void 0),h(l,"shots",void 0),h(l,"firstShot",void 0),h(l,"timer",void 0),h(l,"init",void 0),l.init=t,l.shots=d(r),l.firstShot=l.shots[0],l.delay=u,l.container.table.showTraces(!0),l.container.table.updateFromShortSerialised(l.init),c){var p=new o.W(t,r);p.retry=!0,l.container.eventQueue.push(p)}else l.container.view.camera.forceMode(l.container.view.camera.topView),l.playNextShot(1.5*l.delay);return l}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&p(e,t)}(n,e),t=[{key:"playNextShot",value:function(e){var t=this,n=this.shots.shift();if((null==n?void 0:n.type)===l.B.RERACK){c.x.fromJson(n.ballinfo).applyToController(this),this.shots.length>0&&this.playNextShot(e);return}var i=s.w.fromJson(n);this.container.table.cueball=this.container.table.balls[i.i],console.log(this.container.table.cueball.pos.distanceTo(i.pos)),this.container.table.cueball.pos.copy(i.pos),this.container.table.cue.aim=i,this.container.table.cue.updateAimInput(),this.container.table.cue.t=1,clearTimeout(this.timer),this.timer=setTimeout(function(){t.container.eventQueue.push(new r.Q(t.container.table.cue.aim)),t.timer=void 0},e)}},{key:"handleHit",value:function(e){return this.hit(),this}},{key:"handleStationary",value:function(e){return this.shots.length>0&&void 0===this.timer&&this.playNextShot(this.delay),this}},{key:"handleInput",value:function(e){return this.commonKeyHandler(e),this}},{key:"handleBreak",value:function(e){return(this.container.table.updateFromShortSerialised(e.init),this.shots=d(e.shots),this.container.table.showSpin(!0),e.retry)?this.retry():(this.playNextShot(this.delay),this)}},{key:"retry",value:function(){clearTimeout(this.timer),this.timer=void 0,this.container.table.updateFromShortSerialised(this.init);var e=s.w.fromJson(this.firstShot);return this.container.table.cueball=this.container.table.balls[e.i],this.container.rules.cueball=this.container.table.cueball,this.container.table.cueball.pos.copy(e.pos),this.container.table.cue.aim=e,this.container.view.camera.forceMode(this.container.view.camera.aimView),new a.m(this.container)}}],function(e,t){for(var n=0;n{n.d(t,{V:()=>M});var r=n("./src/events/watchevent.ts"),i=n("./src/utils/rack.ts"),s=n("./node_modules/three/build/three.module.js"),o=n("./src/controller/aim.ts"),a=n("./src/controller/placeball.ts"),l=n("./src/controller/watchaim.ts"),c=n("./src/events/chatevent.ts"),u=n("./src/events/placeballevent.ts"),h=n("./src/model/outcome.ts"),f=n("./src/model/table.ts"),p=n("./src/utils/utils.ts"),d=n("./src/controller/end.ts"),v=n("./src/model/physics/constants.ts"),m=n("./src/utils/respot.ts"),y=n("./src/view/tablegeometry.ts"),b=n("./src/events/startaimevent.ts");function g(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var w=/*#__PURE__*/function(){var e;function t(e){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),g(this,"container",void 0),g(this,"cueball",void 0),g(this,"currentBreak",0),g(this,"previousBreak",0),g(this,"score",0),g(this,"rulename","nineball"),this.container=e}return e=[{key:"startTurn",value:function(){this.previousBreak=this.currentBreak,this.currentBreak=0}},{key:"nextCandidateBall",value:function(){return m.k.closest(this.container.table.cueball,this.container.table.balls)}},{key:"placeBall",value:function(e){if(e){var t=new s.Pq0(-y.P.X/2,y.P.tableY),n=new s.Pq0(-y.P.tableX,-y.P.tableY);return e.clamp(n,t)}return new s.Pq0(-(11*v.R)/.5,0,0)}},{key:"asset",value:function(){return"models/p8.min.gltf"}},{key:"tableGeometry",value:function(){y.P.hasPockets=!0}},{key:"table",value:function(){var e=new f.X(this.rack());return this.cueball=e.cueball,e}},{key:"rack",value:function(){return i.m.diamond()}},{key:"update",value:function(e){var t=this.container.table;if(h.P.isCueBallPotted(t.cueball,e))return(this.startTurn(),this.container.isSinglePlayer)?new a.x(this.container):(this.container.sendEvent(new u.z(p.v_,!0)),new l.r(this.container));if(h.P.isBallPottedNoFoul(t.cueball,e)){var n=h.P.potCount(e);return(this.currentBreak+=n,this.score+=n,this.container.sound.playSuccess(t.inPockets()),this.isEndOfGame(e))?(this.container.eventQueue.push(new c.b(null,"game over")),this.container.recorder.wholeGameLink(),new d.o(this.container)):(this.container.sendEvent(new r.Q(t.serialise())),new o.m(this.container))}return(this.container.sendEvent(new b.M),this.container.isSinglePlayer)?(this.container.sendEvent(new r.Q(t.serialise())),this.startTurn(),new o.m(this.container)):new l.r(this.container)}},{key:"isPartOfBreak",value:function(e){return h.P.isBallPottedNoFoul(this.container.table.cueball,e)}},{key:"isEndOfGame",value:function(e){var t=this.container.table.balls.filter(function(e){return e.onTable()});return 1===t.length&&t[0]===this.cueball}},{key:"otherPlayersCueBall",value:function(){return this.cueball}},{key:"secondToPlay",value:function(){}},{key:"allowsPlaceBall",value:function(){return!0}}],function(e,t){for(var n=0;n{n.d(t,{c:()=>k});var r=n("./node_modules/three/build/three.module.js"),i=n("./src/events/watchevent.ts"),s=n("./src/model/outcome.ts"),o=n("./src/utils/rack.ts"),a=n("./src/utils/respot.ts"),l=n("./src/controller/aim.ts"),c=n("./src/controller/watchaim.ts"),u=n("./src/events/chatevent.ts"),h=n("./src/controller/end.ts"),f=n("./src/model/table.ts"),p=n("./src/view/tablegeometry.ts"),d=n("./src/controller/placeball.ts"),v=n("./src/events/placeballevent.ts"),m=n("./src/utils/utils.ts"),y=/*#__PURE__*/function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t)}return e=[{key:"shotInfo",value:function(e,n,r){var i=s.P.firstCollision(n);return{pots:s.P.potCount(n),firstCollision:i,legalFirstCollision:t.isLegalFirstCollision(e,r,i),whitePotted:s.P.isCueBallPotted(e.cueball,n)}}},{key:"isLegalFirstCollision",value:function(e,n,r){if(!r)return!1;var i=r.ballB.id;return n?i>=7:!(t.coloursOnTable(e).filter(function(e){return e.id0)}},{key:"respotAllPottedColours",value:function(e,t){return s.P.pots(t).filter(function(e){return e.id<7}).filter(function(e){return 0!==e.id}).map(function(t){return a.k.respot(t,e)})}},{key:"redsOnTable",value:function(e){return e.balls.slice(7).filter(function(e){return e.onTable()})}},{key:"coloursOnTable",value:function(e){return e.balls.slice(1,7).filter(function(e){return e.onTable()})}}],function(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,r=Array(t);n0,this.switchPlayer()}return this.targetIsRed?this.targetRedRule(e,t):this.targetColourRule(e,t)}},{key:"targetRedRule",value:function(e,t){return(console.log("applying target red rule"),t.legalFirstCollision&&s.P.onlyRedsPotted(e))?(this.currentBreak+=t.pots,this.targetIsRed=!1,this.previousPotRed=!0,this.container.hud.updateBreak(this.currentBreak),this.continueBreak()):(this.foulPoints=this.foulCalculation(e,t),this.respot(e),t.whitePotted)?this.whiteInHand():this.switchPlayer()}},{key:"targetColourRule",value:function(e,t){if(console.log("applying target colour rule"),t.whitePotted)return this.respot(e),this.whiteInHand();if(t.pots>1)return this.foulPoints=this.foulCalculation(e,t),this.respot(e),this.switchPlayer();if(s.P.pots(e)[0].id>6)return this.foulPoints=this.foulCalculation(e,t),this.switchPlayer();this.targetIsRed=y.redsOnTable(this.container.table).length>0;var n=s.P.pots(e)[0].id;return n!==t.firstCollision.ballB.id?this.foul(e,t):this.previousPotRed?(this.respot(e),this.currentBreak+=n+1,this.previousPotRed=!1,this.continueBreak()):y.coloursOnTable(this.container.table).filter(function(e){return e.id0?this.foul(e,t):(this.currentBreak+=n+1,this.previousPotRed=!1,this.continueBreak())}},{key:"foul",value:function(e,t){return this.foulPoints=this.foulCalculation(e,t),this.respot(e),this.switchPlayer()}},{key:"foulCalculation",value:function(e,t){var n,r,i,o,a=s.P.pots(e).map(function(e){return e.id}).filter(function(e){return e<7}),l=null!==(o=null===(i=t.firstCollision)||void 0===i?void 0:null===(r=i.ballB)||void 0===r?void 0:r.id)&&void 0!==o?o:0;return l>6&&(l=0),(n=Math).max.apply(n,[3,l].concat(function(e){if(Array.isArray(e))return g(e)}(a)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(a)||function(e,t){if(e){if("string"==typeof e)return g(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return g(e,void 0)}}(a)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()))+1}},{key:"tableGeometry",value:function(){p.P.hasPockets=!0}},{key:"table",value:function(){var e=new f.X(this.rack());return this.cueball=e.cueball,e}},{key:"otherPlayersCueBall",value:function(){return this.cueball}},{key:"secondToPlay",value:function(){}},{key:"isPartOfBreak",value:function(e){return this.currentBreak>0}},{key:"isEndOfGame",value:function(e){return s.P.isClearTable(this.container.table)&&this.currentBreak>0}},{key:"allowsPlaceBall",value:function(){return!0}},{key:"asset",value:function(){return t.tablemodel}},{key:"startTurn",value:function(){this.previousPotRed=!1,this.targetIsRed=y.redsOnTable(this.container.table).length>0,this.previousBreak=this.currentBreak,this.score+=this.currentBreak,this.currentBreak=0,this.container.hud.updateBreak(this.currentBreak)}},{key:"rack",value:function(){return o.m.snooker()}},{key:"nextCandidateBall",value:function(){var e=this.container.table,t=y.redsOnTable(e),n=y.coloursOnTable(e);return this.previousPotRed?a.k.closest(e.cueball,n):t.length>0?a.k.closest(e.cueball,t):n.length>0?n[0]:void 0}},{key:"placeBall",value:function(e){if(e){var t=new r.Pq0(o.m.baulk,0,0),n=o.m.sixth,i=e.distanceTo(t);if(e.x>=o.m.baulk&&(e.x=o.m.baulk),!(i>n))return e;var s=e.clone().sub(t).normalize();return t.add(s.multiplyScalar(n))}return new r.Pq0(o.m.baulk,-o.m.sixth/2.6,0)}},{key:"switchPlayer",value:function(){this.foulPoints>0&&console.log("foul, ".concat(this.foulPoints," to opponent")),console.log("end of break, switch player");var e=this.container.table;return(console.log(e.cue.aim),this.container.sendEvent(new b.M(this.foulPoints)),this.container.isSinglePlayer)?(this.container.sendEvent(new i.Q(e.serialise())),this.startTurn(),new l.m(this.container)):new c.r(this.container)}},{key:"continueBreak",value:function(){this.container.hud.updateBreak(this.currentBreak);var e=this.container.table;return(this.container.sound.playSuccess(e.inPockets()),s.P.isClearTable(e))?(this.container.eventQueue.push(new u.b(null,"game over")),this.container.recorder.wholeGameLink(),new h.o(this.container)):(this.container.sendEvent(new i.Q(e.serialise())),new l.m(this.container))}},{key:"whiteInHand",value:function(){return(this.foulPoints>0&&console.log("foul, ".concat(this.foulPoints," to opponent")),this.startTurn(),this.container.isSinglePlayer)?new d.x(this.container):(this.container.sendEvent(new v.z(m.v_,!0)),new c.r(this.container))}},{key:"update",value:function(e){return this.snookerrule(e)}},{key:"respot",value:function(e){var t=y.respotAllPottedColours(this.container.table,e);if(t.length>0){var n={balls:t.map(function(e){return e.serialise()}),rerack:!0},r=new i.Q(n);this.container.sendEvent(r),this.container.recorder.record(r)}}}],function(e,t){for(var n=0;n{n.d(t,{r:()=>a});var r=n("./src/controller/watchshot.ts");function i(e){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function o(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(o=function(){return!!e})()}var a=/*#__PURE__*/function(e){var t;function n(e){var t,r,s,a;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,n),r=n,s=[e],r=i(r),(t=(a=o()?Reflect.construct(r,s||[],i(this).constructor):r.apply(this,s))&&("object"==(a&&"undefined"!=typeof Symbol&&a.constructor===Symbol?"symbol":typeof a)||"function"==typeof a)?a:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this)).container.table.cueball=t.container.rules.otherPlayersCueBall(),t.container.table.cue.moveTo(t.container.table.cueball.pos),t.container.view.camera.suggestMode(t.container.view.camera.topView),t}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}(n,e),t=[{key:"handleAim",value:function(e){return this.container.table.cue.aim=e,this.container.table.cueball.pos.copy(e.pos),this}},{key:"handleHit",value:function(e){return this.container.table.updateFromSerialised(e.tablejson),new r.O(this.container)}}],function(e,t){for(var n=0;n{n.d(t,{O:()=>u});var r=n("./src/controller/aim.ts"),i=n("./src/controller/watchaim.ts"),s=n("./src/controller/controllerbase.ts"),o=n("./src/controller/placeball.ts");function a(e){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function l(e,t){return(l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(c=function(){return!!e})()}var u=/*#__PURE__*/function(e){var t;function n(e){var t,r,i,s;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,n),r=n,i=[e],r=a(r),(t=(s=c()?Reflect.construct(r,i||[],a(this).constructor):r.apply(this,i))&&("object"==(s&&"undefined"!=typeof Symbol&&s.constructor===Symbol?"symbol":typeof s)||"function"==typeof s)?s:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this)).container.table.outcome=[],t.container.table.hit(),t}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&l(e,t)}(n,e),t=[{key:"handleStartAim",value:function(e){return new r.m(this.container)}},{key:"handlePlaceBall",value:function(e){return new o.x(this.container)}},{key:"handleWatch",value:function(e){return"rerack"in e.json?(console.log("Respot"),this.container.table.updateFromSerialised(e.json),this):new i.r(this.container)}}],function(e,t){for(var n=0;n{n.d(t,{M:()=>r,R:()=>i,_:()=>a,ee:()=>s,o:()=>o});var r=.1406,i=.02625,s=.98,o=.212,a=.14},"./src/events/abortevent.ts":(e,t,n)=>{n.d(t,{h:()=>l});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function a(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(a=function(){return!!e})()}var l=/*#__PURE__*/function(e){var t;function n(){var e,t,r,o;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,n),t=s(t=n),(e=(o=a()?Reflect.construct(t,[],s(this).constructor):t.apply(this,r))&&("object"==(o&&"undefined"!=typeof Symbol&&o.constructor===Symbol?"symbol":typeof o)||"function"==typeof o)?o:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this)).type=i.B.ABORT,e}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&o(e,t)}(n,e),t=[{key:"applyToController",value:function(e){return e.handleAbort(this)}}],function(e,t){for(var n=0;n{n.d(t,{w:()=>f});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts"),s=n("./src/utils/utils.ts"),o=n("./node_modules/three/build/three.module.js");function a(e,t){for(var n=0;n{n.d(t,{u:()=>l});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function a(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(a=function(){return!!e})()}var l=/*#__PURE__*/function(e){var t;function n(){var e,t,r,o;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,n),t=s(t=n),(e=(o=a()?Reflect.construct(t,[],s(this).constructor):t.apply(this,r))&&("object"==(o&&"undefined"!=typeof Symbol&&o.constructor===Symbol?"symbol":typeof o)||"function"==typeof o)?o:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this)).type=i.B.BEGIN,e}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&o(e,t)}(n,e),t=[{key:"applyToController",value:function(e){return e.handleBegin(this)}}],function(e,t){for(var n=0;n{n.d(t,{W:()=>u});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function s(e,t){for(var n=0;n{n.d(t,{b:()=>u});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function s(e,t){for(var n=0;n{n.d(t,{B:()=>r});var r=/*#__PURE__*/function(e){return e.BEGIN="BEGIN",e.BREAK="BREAK",e.WATCHAIM="WATCHAIM",e.AIM="AIM",e.HIT="HIT",e.STATIONARY="STATIONARY",e.CHAT="CHAT",e.ABORT="ABORT",e.PLACEBALL="PLACEBALL",e.REJOIN="REJOIN",e.RERACK="RERACK",e.STARTAIM="STARTAIM",e}({})},"./src/events/gameevent.ts":(e,t,n)=>{function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}n.d(t,{F:()=>i});var i=function e(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,e),r(this,"type",void 0),r(this,"sequence",void 0)}},"./src/events/hitevent.ts":(e,t,n)=>{n.d(t,{Q:()=>c});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function s(e,t){for(var n=0;n{function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}n.d(t,{p:()=>i});var i=function e(t,n){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,e),r(this,"t",void 0),r(this,"key",void 0),this.t=t,this.key=n}},"./src/events/keyboard.ts":(e,t,n)=>{n.d(t,{s:()=>a});var r=n("./src/events/input.ts"),i=n("./node_modules/interactjs/dist/interact.min.js"),s=/*#__PURE__*/n.n(i);function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var a=/*#__PURE__*/function(){var e;function t(e){var n=this;!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),o(this,"pressed",{}),o(this,"released",{}),o(this,"keydown",function(e){null==n.pressed[e.code]&&(n.pressed[e.code]=performance.now()),e.stopImmediatePropagation(),"F12"!==e.key&&e.preventDefault()}),o(this,"keyup",function(e){n.released[e.code]=performance.now()-n.pressed[e.code],delete n.pressed[e.code],e.stopImmediatePropagation(),"F12"!==e.key&&e.preventDefault()}),o(this,"mousetouch",function(e){var t,r,i=n.released,s=e.client.yMath.abs(i.movementY)&&(i.movementY=0)}),this.addHandlers(e),/Android|iPhone/i.test(navigator.userAgent)||(e.contentEditable="true")}return e=[{key:"getEvents",value:function(){var e=this,t=Object.keys(this.pressed).filter(function(e){return!/Shift/.test(e)}).filter(function(e){return!/Control/.test(e)}),n=Object.keys(this.pressed).some(function(e){return/Shift/.test(e)}),i=Object.keys(this.pressed).some(function(e){return/Control/.test(e)}),s=[];return t.forEach(function(t){var o=performance.now()-e.pressed[t];s.push(new r.p(i?o/3:o,n?"Shift"+t:t)),"Space"!=t&&(e.pressed[t]=performance.now())}),Object.keys(this.released).forEach(function(t){return s.push(new r.p(e.released[t],t+"Up"))}),this.released={},s}},{key:"addHandlers",value:function(e){var t=this;e.addEventListener("keydown",this.keydown),e.addEventListener("keyup",this.keyup),e.focus(),s()(e).draggable({listeners:{move:function(e){t.mousetouch(e)}}}),s()(e).gesturable({onmove:function(e){e.dx/=3,t.mousetouch(e)}})}}],function(e,t){for(var n=0;n{n.d(t,{z:()=>h});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts"),s=n("./src/utils/utils.ts");function o(e,t){for(var n=0;n{n.d(t,{x:()=>c});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function s(e,t){for(var n=0;n{n.d(t,{M:()=>c});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function s(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:0;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,r),t=o(t=r),(s="foul")in(a=(e=l()?Reflect.construct(t,[],o(this).constructor):t.apply(this,n))&&("object"==(e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e)||"function"==typeof e)?e:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this))?Object.defineProperty(a,s,{value:0,enumerable:!0,configurable:!0,writable:!0}):a[s]=0,a.type=i.B.STARTAIM,a.foul=c,a}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&a(e,t)}(r,e),t=[{key:"applyToController",value:function(e){return e.handleStartAim(this)}}],n=[{key:"fromJson",value:function(e){return new r(e.foul)}}],t&&s(r.prototype,t),n&&s(r,n),r}(r.F)},"./src/events/stationaryevent.ts":(e,t,n)=>{n.d(t,{T:()=>l});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function a(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(a=function(){return!!e})()}var l=/*#__PURE__*/function(e){var t;function n(){var e,t,r,o;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,n),t=s(t=n),(e=(o=a()?Reflect.construct(t,[],s(this).constructor):t.apply(this,r))&&("object"==(o&&"undefined"!=typeof Symbol&&o.constructor===Symbol?"symbol":typeof o)||"function"==typeof o)?o:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this)).type=i.B.STATIONARY,e}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&o(e,t)}(n,e),t=[{key:"applyToController",value:function(e){return e.handleStationary(this)}}],function(e,t){for(var n=0;n{n.d(t,{Q:()=>c});var r=n("./src/events/gameevent.ts"),i=n("./src/events/eventtype.ts");function s(e,t){for(var n=0;n{var r=n("./src/container/container.ts"),i=n("./src/events/keyboard.ts"),s=n("./src/events/eventtype.ts"),o=n("./src/events/aimevent.ts"),a=n("./src/events/watchevent.ts"),l=n("./src/events/hitevent.ts"),c=n("./src/events/abortevent.ts"),u=n("./src/events/breakevent.ts"),h=n("./src/events/beginevent.ts"),f=n("./src/events/chatevent.ts");function p(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:"",a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,r),t=v(t=r),d(i=(e=y()?Reflect.construct(t,[],v(this).constructor):t.apply(this,n))&&("object"==(e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e)||"function"==typeof e)?e:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this),"clientResendFrom",void 0),d(i,"serverResendFrom",void 0),i.type=s.B.REJOIN,i.clientResendFrom=o,i.serverResendFrom=a,i}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&m(e,t)}(r,e),t=[{key:"applyToController",value:function(e){return e.handleRejoin(this)}}],n=[{key:"fromJson",value:function(e){return new r(e.clientResendFrom,e.serverResendFrom)}}],t&&p(r.prototype,t),n&&p(r,n),r}(n("./src/events/gameevent.ts").F),g=n("./src/events/placeballevent.ts"),w=n("./src/events/rerackevent.ts"),k=n("./src/events/startaimevent.ts"),T=/*#__PURE__*/function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t)}return e=[{key:"serialise",value:function(e){return JSON.stringify(e)}},{key:"fromJson",value:function(e){switch(e.type){case s.B.BEGIN:return new h.u;case s.B.AIM:return o.w.fromJson(e);case s.B.BREAK:return u.W.fromJson(e);case s.B.WATCHAIM:return a.Q.fromJson(e.json);case s.B.HIT:return l.Q.fromJson(e);case s.B.CHAT:return f.b.fromJson(e);case s.B.REJOIN:return b.fromJson(e);case s.B.ABORT:return new c.h;case s.B.PLACEBALL:return g.z.fromJson(e);case s.B.RERACK:return w.x.fromJson(e);case s.B.STARTAIM:return k.M.fromJson(e);default:throw Error("Unknown GameEvent :"+e)}}},{key:"fromSerialised",value:function(e){var n=JSON.parse(e),r=t.fromJson(n);return"sequence"in n&&(r.sequence=n.sequence),r}}],function(e,t){for(var n=0;n upload high score \uD83C\uDFC6{n.d(t,{c:()=>d,U:()=>p});var r=n("./src/utils/utils.ts"),i=n("./src/model/physics/physics.ts"),s=n("./node_modules/three/build/three.module.js"),o=n("./src/model/physics/constants.ts");function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var l=/*#__PURE__*/function(){var e;function t(e,n){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),a(this,"line",void 0),a(this,"geometry",void 0),a(this,"positions",void 0),a(this,"lastPos",new s.Pq0),a(this,"lastVel",new s.Pq0),this.geometry=new s.LoY,this.positions=new Float32Array(3*e),this.geometry.setAttribute("position",new s.THS(this.positions,3)),this.reset();var r=new s.mrM({color:n,opacity:.25,linewidth:3,transparent:!0});this.line=new s.N1A(this.geometry,r),this.line.visible=!1}return e=[{key:"reset",value:function(){this.geometry.setDrawRange(0,0),this.lastVel.setZ(1)}},{key:"forceTrace",value:function(e){this.lastVel.z=1,this.addTraceGiven(e,this.lastVel,1,.1,1)}},{key:"addTrace",value:function(e,t){if(0!==t.length()){var n=this.lastVel.angleTo(t),r=n>Math.PI/32?.01*o.R:o.R,i=this.lastPos.distanceTo(e);this.addTraceGiven(e,t,i,r,n)}}},{key:"addTraceGiven",value:function(e,t,n,r,i){var s=this.geometry.drawRange.count;0!==s&&n1&&i<1e-4&&s--,this.lastPos.copy(e),this.lastVel.copy(t),this.addPoint(e,s))}},{key:"addPoint",value:function(e,t){var n=3*t;n>this.positions.length||(this.positions[n++]=e.x,this.positions[n++]=e.y,this.positions[n]=e.z,this.geometry.setDrawRange(0,t+1),this.line.geometry.attributes.position.needsUpdate=!0)}}],function(e,t){for(var n=0;nMath.abs(this.rvel.z))&&(this.setStationary(),!0)}},{key:"setStationary",value:function(){this.vel.copy(r.v_),this.rvel.copy(r.v_),this.state="Stationary"}},{key:"isRolling",value:function(){return 0!==this.vel.lengthSq()&&0!==this.rvel.lengthSq()&&(0,i.Mq)(this.vel,this.rvel).length(){function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}n.d(t,{P:()=>i});var i=/*#__PURE__*/function(){var e;function t(e,n,i,s){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),r(this,"type",void 0),r(this,"timestamp",void 0),r(this,"ballA",null),r(this,"ballB",null),r(this,"incidentSpeed",void 0),this.type=e,this.ballA=n,this.ballB=i,this.incidentSpeed=s,this.timestamp=Date.now()}return e=[{key:"pot",value:function(e,n){return new t("Pot",e,e,n)}},{key:"cushion",value:function(e,n){return new t("Cushion",e,e,n)}},{key:"collision",value:function(e,n,r){return new t("Collision",e,n,r)}},{key:"hit",value:function(e,n){return new t("Hit",e,e,n)}},{key:"isCueBallPotted",value:function(e,t){return t.some(function(t){return"Pot"==t.type&&t.ballA===e})}},{key:"isBallPottedNoFoul",value:function(e,n){return n.some(function(e){return"Pot"==e.type&&null!==e.ballA})&&!t.isCueBallPotted(e,n)}},{key:"pots",value:function(e){return e.filter(function(e){return"Pot"==e.type}).map(function(e){return e.ballA})}},{key:"potCount",value:function(e){return this.pots(e).length}},{key:"onlyRedsPotted",value:function(e){return this.pots(e).every(function(e){return e.id>6})}},{key:"firstCollision",value:function(e){var t=e.filter(function(e){return"Collision"===e.type});return t.length>0?t[0]:void 0}},{key:"isClearTable",value:function(e){var t=e.balls.filter(function(e){return e.onTable()});return 1===t.length&&t[0]===e.cueball}},{key:"isThreeCushionPoint",value:function(e,n){n=t.cueBallFirst(e,n).filter(function(t){return t.ballA===e});var r=new Set,i=0,s=!0,o=!1,a=void 0;try{for(var l,c=n[Symbol.iterator]();!(s=(l=c.next()).done);s=!0){var u=l.value;if("Cushion"===u.type&&i++,"Collision"===u.type&&(r.add(u.ballB),2===r.size))return i>=3}}catch(e){o=!0,a=e}finally{try{s||null==c.return||c.return()}finally{if(o)throw a}}return!1}},{key:"cueBallFirst",value:function(e,t){return t.forEach(function(t){"Collision"===t.type&&t.ballB===e&&(t.ballB=t.ballA,t.ballA=e)}),t}}],function(e,t){for(var n=0;n{n.d(t,{I:()=>s,Mz:()=>r,Qg:()=>b,R:()=>f,Wv:()=>w,Ys:()=>k,Z3:()=>d,cM:()=>T,e:()=>p,g:()=>o,gT:()=>c,gf:()=>l,jG:()=>y,kL:()=>u,kM:()=>A,m:()=>h,mu:()=>a,o5:()=>v,x3:()=>i,xO:()=>g});var r,i,s,o=9.8,a=.00985,l=.16,c=.8,u=.034,h=.23,f=.03275,p=.86,d=.4,v=Math.sqrt(21)/5;function m(){r=a*h*o*2/3*u,i=7/(5*Math.sqrt(2))*f*a*h*o,s=.4*h*f*f}function y(e){f=e,m()}function b(e){h=e,m()}function g(e){a=e,m()}function w(e){u=e,m()}function k(e){l=e}function T(e){p=e}function A(e){c=e}m()},"./src/model/physics/knuckle.ts":(e,t,n)=>{n.d(t,{O:()=>a});var r=n("./src/model/physics/constants.ts"),i=n("./src/view/pocketgeometry.ts");function s(e,t){for(var n=0;n{n.d(t,{z:()=>s});var r=n("./src/model/physics/constants.ts");function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var s=/*#__PURE__*/function(){var e;function t(e,n,r,s,o){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),i(this,"P",0),i(this,"WzI",0),i(this,"vx",void 0),i(this,"vy",void 0),i(this,"ωx",void 0),i(this,"ωy",void 0),i(this,"ωz",void 0),i(this,"s",void 0),i(this,"φ",void 0),i(this,"sʹ",void 0),i(this,"φʹ",void 0),i(this,"i",0),i(this,"N",100),i(this,"M",void 0),i(this,"R",void 0),i(this,"μs",void 0),i(this,"μw",void 0),i(this,"ee",void 0),this.M=e,this.R=n,this.ee=r,this.μs=s,this.μw=o}return e=[{key:"updateSlipSpeedsAndAngles",value:function(){var e=this.R,t=this.vx+this.ωy*e*r.Z3-this.ωz*e*r.o5,n=-this.vy*r.Z3+this.ωx*e,i=this.vx-this.ωy*e,s=this.vy+this.ωx*e;this.s=Math.sqrt(Math.pow(t,2)+Math.pow(n,2)),this.φ=Math.atan2(n,t),this.φ<0&&(this.φ+=2*Math.PI),this.sʹ=Math.sqrt(Math.pow(i,2)+Math.pow(s,2)),this.φʹ=Math.atan2(s,i),this.φʹ<0&&(this.φʹ+=2*Math.PI)}},{key:"compressionPhase",value:function(){for(var e=Math.max(this.M*this.vy/this.N,.001);this.vy>0;)this.updateSingleStep(e)}},{key:"restitutionPhase",value:function(e){var t=Math.max(e/this.N,.001);for(this.WzI=0;this.WzI10*this.N)throw"Solution not found"}},{key:"updateVelocity",value:function(e){var t=this.μs,n=this.μw,i=this.M;this.vx-=1/i*(n*Math.cos(this.φ)+t*Math.cos(this.φʹ)*(r.Z3+n*Math.sin(this.φ)*r.o5))*e,this.vy-=1/i*(r.o5-n*r.Z3*Math.sin(this.φ)+t*Math.sin(this.φʹ)*(r.Z3+n*Math.sin(this.φ)*r.o5))*e}},{key:"updateAngularVelocity",value:function(e){var t=this.μs,n=this.μw,i=this.M,s=this.R;this.ωx+=-(5/(2*i*s))*(n*Math.sin(this.φ)+t*Math.sin(this.φʹ)*(r.Z3+n*Math.sin(this.φ)*r.o5))*e,this.ωy+=-(5/(2*i*s))*(n*Math.cos(this.φ)*r.Z3-t*Math.cos(this.φʹ)*(r.Z3+n*Math.sin(this.φ)*r.o5))*e,this.ωz+=5/(2*i*s)*(n*Math.cos(this.φ)*r.o5)*e}},{key:"updateWorkDone",value:function(e){var t=e*Math.abs(this.vy);this.WzI+=t,this.P+=e}},{key:"solvePaper",value:function(e,t,n,r){this.solve(e*Math.cos(t),e*Math.sin(t),-r*Math.sin(t),r*Math.cos(t),n)}},{key:"solve",value:function(e,t,n,r,i){this.vx=e,this.vy=t,this.ωx=n,this.ωy=r,this.ωz=i,this.WzI=0,this.P=0,this.i=0,this.compressionPhase();var s=this.WzI-(1-this.ee*this.ee)*this.WzI;this.restitutionPhase(s)}}],function(e,t){for(var n=0;n{n.d(t,{$8:()=>S,Gp:()=>k,JD:()=>f,Mq:()=>c,QK:()=>d,QV:()=>R,Qy:()=>M,Un:()=>w,c0:()=>g,lx:()=>p,p2:()=>h,s0:()=>b,t6:()=>_,yO:()=>T});var r=n("./node_modules/three/build/three.module.js"),i=n("./src/utils/utils.ts"),s=n("./src/model/physics/constants.ts"),o=n("./src/model/physics/mathaven.ts"),a=n("./src/diagram/constants.ts"),l=new r.Pq0;function c(e,t){return l.copy(e).addScaledVector((0,i.KM)(t),s.R)}var u={v:new r.Pq0,w:new r.Pq0};function h(e,t){var n=c(e,t).setZ(0);return u.v.copy((0,i.xb)(n).multiplyScalar(-s.gf*s.g)),u.w.copy((0,i.xb)((0,i.KM)(n)).multiplyScalar(2.5*s.gf*s.g/s.R)),u.w.setZ(-2.5*(s.Mz/(s.m*s.R*s.R))*Math.sign(t.z)),u}function f(e){var t=new r.Pq0(e.x,e.y,0).length(),n=5/7*s.x3/(s.m*s.R)/t,i=5/7*s.x3/(s.m*s.R*s.R)/t;return u.v.set(-n*e.y,n*e.x,0),u.w.set(-i*e.x,-i*e.y,-2.5*(s.Mz/(s.m*s.R*s.R))*Math.sign(e.z)),u}function p(e,t){var n=t.z;t.copy((0,i.KM)(e).multiplyScalar(1/s.R)),t.setZ(n)}function d(e,t,n,r){var s=r(t.clone().applyAxisAngle(i.up,e),n.clone().applyAxisAngle(i.up,e));return s.v.applyAxisAngle(i.up,-e),s.w.applyAxisAngle(i.up,-e),s}Object.freeze(u);var v=Math.asin(.1*s.R/s.R),m=Math.sin(v),y=Math.cos(v);function b(e,t){return new r.Pq0(e.x*m-e.z*y+s.R*t.y,-e.y-s.R*t.z*y+s.R*t.x*m)}function g(e){return e.x*y}function w(e){var t=3.5/s.m;return e.length()/t}function k(e){var t,n=1/s.m,i=.39+.257*(t=new r.Pq0(e/y,0,0)).x-.044*t.x*t.x;return s.gT*((1+i)*e)/n}function T(e,t){var n=k(g(e));return w(b(e,t))<=n}function A(e,t){return{c:g(e),s:b(e,t),A:3.5/s.m,B:1/s.m}}function x(e,t){var n=A(e,t),r=n.c,i=n.s,o=n.A,a=n.B,l=(1+s.e)*(r/a);return E(-i.x/o*m-l*y,i.y/o,i.x/o*y-l*m)}function P(e,t){var n=A(e,t),r=n.c,i=n.B,o=(1+s.e)*(r/i),a=.471-.241*Math.atan2(Math.abs(e.y),e.x),l=Math.atan2(e.y,e.x),c=Math.cos(l);return E(-a*o*c*y-o*y,a*o*Math.sin(l),a*o*c*y-o*m)}function R(e,t){return T(e,t)?x(e,t):P(e,t)}function S(e,t){var n=x(e,t),r=P(e,t),i=Math.sign(e.y)===Math.sign(t.z)?Math.cos(Math.atan2(e.y,e.x)):1;return{v:r.v.lerp(n.v,i),w:r.w.lerp(n.w,i)}}function E(e,t,n){return{v:new r.Pq0(e/s.m,t/s.m),w:new r.Pq0(-s.R/s.I*t*m,s.R/s.I*(e*m-n*y),s.R/s.I*t*y)}}function O(e,t){var n=new o.z(s.m,s.R,a.ee,a.o,a._+.1);n.solve(e.x,e.y,t.x,t.y,t.z);var i=new r.Pq0(n.vx,n.vy,0),l=new r.Pq0(n.ωx,n.ωy,n.ωz);return{v:i.sub(e),w:l.sub(t)}}function M(e,t){return d(Math.PI/2,e,t,O)}function _(e,t){var n=Math.atan2(-e.x,e.y),r=2.5*t.length()*(e.length()*s.R)/(s.R*s.R),o=t.clone().normalize();return(0,i.KM)(o).applyAxisAngle(o,n).multiplyScalar(r)}},"./src/model/physics/pocket.ts":(e,t,n)=>{n.d(t,{Z:()=>l});var r=n("./src/model/ball.ts"),i=n("./src/model/physics/constants.ts"),s=n("./src/utils/utils.ts");function o(e,t){for(var n=0;nthis.radius-i.R){var o=this.pos.clone().sub(e.pos).normalize().setZ(0);n>-i.R/2&&(e.vel.addScaledVector(o,7*i.R*t*i.g),e.rvel.addScaledVector((0,s.KM)(o),7*t*i.g)),0>e.vel.dot(o)&&(e.ballmesh.trace.forceTrace(e.pos),e.vel.x=o.x*e.vel.length()/2,e.vel.y=o.y*e.vel.length()/2)}var a=this.restingDepth(e);n{n.d(t,{X:()=>b});var r=n("./src/view/tablegeometry.ts"),i=n("./src/model/physics/physics.ts"),s=n("./src/view/pocketgeometry.ts"),o=/*#__PURE__*/function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t)}return e=[{key:"bounceAny",value:function(e,n){var s=!(arguments.length>2)||void 0===arguments[2]||arguments[2],o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:i.$8,a=e.futurePosition(n);if(t.willBounceLong(a,s)){var l=a.y>r.P.tableY?-Math.PI/2:Math.PI/2;return t.bounceIn(l,e,o)}if(t.willBounceShort(a,s)){var c=a.x>r.P.tableX?0:Math.PI;return t.bounceIn(c,e,o)}}},{key:"willBounceShort",value:function(e,n){return n?t.willBounceShortSegment(s.f.pockets.pocketNW.knuckleSW.pos.y,s.f.pockets.pocketSW.knuckleNW.pos.y,e):t.willBounceShortSegment(r.P.Y,-r.P.Y,e)}},{key:"willBounceLong",value:function(e,n){return n?t.willBounceLongSegment(s.f.pockets.pocketNW.knuckleNE.pos.x,s.f.pockets.pocketN.knuckleNW.pos.x,e)||t.willBounceLongSegment(s.f.pockets.pocketN.knuckleNE.pos.x,s.f.pockets.pocketNE.knuckleNW.pos.x,e):t.willBounceLongSegment(-r.P.X,r.P.X,e)}},{key:"willBounceLongSegment",value:function(e,t,n){return n.x>e&&n.xr.P.tableY}},{key:"willBounceShortSegment",value:function(e,t,n){return n.y>t&&n.yr.P.tableX}},{key:"bounceIn",value:function(e,t,n){t.ballmesh.trace.forceTrace(t.futurePos);var r=(0,i.QK)(e,t.vel,t.rvel,n);return t.vel.add(r.v),t.rvel.add(r.w),r.v.length()}}],function(e,t){for(var n=0;n100)throw Error("Depth exceeded resolving collisions");this.balls.forEach(function(t){t.update(e)})}},{key:"prepareAdvanceAll",value:function(e){var t=this;return this.pairs.every(function(n){return t.prepareAdvancePair(n.a,n.b,e)})&&this.balls.every(function(n){return t.prepareAdvanceToCushions(n,e)})}},{key:"prepareAdvancePair",value:function(e,t,n){if(u.willCollide(e,t,n)){var r=u.collide(e,t);return this.outcome.push(v.P.collision(e,t,r)),!1}return!0}},{key:"prepareAdvanceToCushions",value:function(e,t){if(!e.onTable())return!0;var n=e.futurePosition(t);if(Math.abs(n.y)1&&void 0!==arguments[1]?arguments[1]:this.cueball;return this.balls.filter(function(e){return e!==t}).some(function(t){return t.pos.distanceTo(e)<2*c.R})}}],t=[{key:"fromSerialised",value:function(e){var t=new n(e.balls.map(function(e){return l.c.fromSerialised(e)}));return t.updateFromSerialised(e),t}}],e&&m(n.prototype,e),t&&m(n,t),n}()},"./src/utils/gltf.ts":(e,t,n)=>{n.d(t,{KP:()=>eR,Ro:()=>eS});var r=n("./node_modules/three/build/three.module.js");let i={POSITION:["byte","byte normalized","unsigned byte","unsigned byte normalized","short","short normalized","unsigned short","unsigned short normalized"],NORMAL:["byte normalized","short normalized"],TANGENT:["byte normalized","short normalized"],TEXCOORD:["byte","byte normalized","unsigned byte","short","short normalized","unsigned short"]};class s{constructor(){this.textureUtils=null,this.pluginCallbacks=[],this.register(function(e){return new y(e)}),this.register(function(e){return new b(e)}),this.register(function(e){return new T(e)}),this.register(function(e){return new A(e)}),this.register(function(e){return new x(e)}),this.register(function(e){return new P(e)}),this.register(function(e){return new g(e)}),this.register(function(e){return new w(e)}),this.register(function(e){return new k(e)}),this.register(function(e){return new R(e)}),this.register(function(e){return new S(e)}),this.register(function(e){return new E(e)}),this.register(function(e){return new O(e)}),this.register(function(e){return new M(e)})}register(e){return -1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return -1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}setTextureUtils(e){return this.textureUtils=e,this}parse(e,t,n,r){let i=new m,s=[];for(let e=0,t=this.pluginCallbacks.length;ee.toBlob(n,t)):("image/jpeg"===t?n=.92:"image/webp"===t&&(n=.8),e.convertToBlob({type:t,quality:n}))}class m{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.extensionsRequired={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter r"+r.sPf}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map},this.textureUtils=null}setPlugins(e){this.plugins=e}setTextureUtils(e){this.textureUtils=e}async writeAsync(e,t,n={}){this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},n),this.options.animations.length>0&&(this.options.trs=!0),await this.processInputAsync(e),await Promise.all(this.pending);let r=this.buffers,i=this.json;n=this.options;let s=this.extensionsUsed,o=this.extensionsRequired,a=new Blob(r,{type:"application/octet-stream"}),l=Object.keys(s),c=Object.keys(o);if(l.length>0&&(i.extensionsUsed=l),c.length>0&&(i.extensionsRequired=c),i.buffers&&i.buffers.length>0&&(i.buffers[0].byteLength=a.size),!0===n.binary){let e=new FileReader;e.readAsArrayBuffer(a),e.onloadend=function(){var n;let r=p(e.result),s=new DataView(new ArrayBuffer(8));s.setUint32(0,r.byteLength,!0),s.setUint32(4,5130562,!0);let o=p((n=JSON.stringify(i),new TextEncoder().encode(n).buffer),32),a=new DataView(new ArrayBuffer(8));a.setUint32(0,o.byteLength,!0),a.setUint32(4,0x4e4f534a,!0);let l=new ArrayBuffer(12),c=new DataView(l);c.setUint32(0,0x46546c67,!0),c.setUint32(4,2,!0);let u=12+a.byteLength+o.byteLength+s.byteLength+r.byteLength;c.setUint32(8,u,!0);let h=new Blob([l,a,o,s,r],{type:"application/octet-stream"}),f=new FileReader;f.readAsArrayBuffer(h),f.onloadend=function(){t(f.result)}}}else if(i.buffers&&i.buffers.length>0){let e=new FileReader;e.readAsDataURL(a),e.onloadend=function(){let n=e.result;i.buffers[0].uri=n,t(i)}}else t(i)}serializeUserData(e,t){if(0===Object.keys(e.userData).length)return;let n=this.options,r=this.extensionsUsed;try{let i=JSON.parse(JSON.stringify(e.userData));if(n.includeCustomExtensions&&i.gltfExtensions){for(let e in void 0===t.extensions&&(t.extensions={}),i.gltfExtensions)t.extensions[e]=i.gltfExtensions[e],r[e]=!0;delete i.gltfExtensions}Object.keys(i).length>0&&(t.extras=i)}catch(t){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+t.message)}}getUID(e,t=!1){if(!1===this.uids.has(e)){let t=new Map;t.set(!0,this.uid++),t.set(!1,this.uid++),this.uids.set(e,t)}return this.uids.get(e).get(t)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;let t=new r.Pq0;for(let n=0,r=e.count;n5e-4)return!1;return!0}createNormalizedNormalAttribute(e){let t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);let n=e.clone(),i=new r.Pq0;for(let e=0,t=n.count;e4?i=e.array[s*e.itemSize+n]:(0===n?i=e.getX(s):1===n?i=e.getY(s):2===n?i=e.getZ(s):3===n&&(i=e.getW(s)),!0===e.normalized&&(i=r.cj9.normalize(i,e.array))),t===o.FLOAT?h.setFloat32(p,i,!0):t===o.INT?h.setInt32(p,i,!0):t===o.UNSIGNED_INT?h.setUint32(p,i,!0):t===o.SHORT?h.setInt16(p,i,!0):t===o.UNSIGNED_SHORT?h.setUint16(p,i,!0):t===o.BYTE?h.setInt8(p,i):t===o.UNSIGNED_BYTE&&h.setUint8(p,i),p+=a}p%c!=0&&(p+=c-p%c)}let d={buffer:this.processBuffer(h.buffer),byteOffset:this.byteOffset,byteLength:u};return void 0!==s&&(d.target=s),s===o.ARRAY_BUFFER&&(d.byteStride=c),this.byteOffset+=u,l.bufferViews.push(d),{id:l.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){let t=this,n=t.json;return n.bufferViews||(n.bufferViews=[]),new Promise(function(r){let i=new FileReader;i.readAsArrayBuffer(e),i.onloadend=function(){let e=p(i.result),s={buffer:t.processBuffer(e),byteOffset:t.byteOffset,byteLength:e.byteLength};t.byteOffset+=e.byteLength,r(n.bufferViews.push(s)-1)}})}processAccessor(e,t,n,i){let s,a;let l=this.json;if(e.array.constructor===Float32Array)s=o.FLOAT;else if(e.array.constructor===Int32Array)s=o.INT;else if(e.array.constructor===Uint32Array)s=o.UNSIGNED_INT;else if(e.array.constructor===Int16Array)s=o.SHORT;else if(e.array.constructor===Uint16Array)s=o.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)s=o.BYTE;else if(e.array.constructor===Uint8Array)s=o.UNSIGNED_BYTE;else throw Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+e.array.constructor.name);if(void 0===n&&(n=0),(void 0===i||i===1/0)&&(i=e.count),0===i)return null;let c=function(e,t,n){let i={min:Array(e.itemSize).fill(Number.POSITIVE_INFINITY),max:Array(e.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let s=t;s4?n=e.array[s*e.itemSize+t]:(0===t?n=e.getX(s):1===t?n=e.getY(s):2===t?n=e.getZ(s):3===t&&(n=e.getW(s)),!0===e.normalized&&(n=r.cj9.normalize(n,e.array))),i.min[t]=Math.min(i.min[t],n),i.max[t]=Math.max(i.max[t],n)}return i}(e,n,i);void 0!==t&&(a=e===t.index?o.ELEMENT_ARRAY_BUFFER:o.ARRAY_BUFFER);let u=this.processBufferView(e,s,n,i,a),h={bufferView:u.id,byteOffset:u.byteOffset,componentType:s,count:i,max:c.max,min:c.min,type:{1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"}[e.itemSize]};return!0===e.normalized&&(h.normalized=!0),l.accessors||(l.accessors=[]),l.accessors.push(h)-1}processImage(e,t,n,i="image/png"){if(null!==e){let s=this,o=s.cache,a=s.json,l=s.options,c=s.pending;o.images.has(e)||o.images.set(e,{});let u=o.images.get(e),h=i+":flipY/"+n.toString();if(void 0!==u[h])return u[h];a.images||(a.images=[]);let f={mimeType:i},p=d();p.width=Math.min(e.width,l.maxTextureSize),p.height=Math.min(e.height,l.maxTextureSize);let m=p.getContext("2d",{willReadFrequently:!0});if(!0===n&&(m.translate(0,p.height),m.scale(1,-1)),void 0!==e.data){t!==r.GWd&&console.error("GLTFExporter: Only RGBAFormat is supported.",t),(e.width>l.maxTextureSize||e.height>l.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);let n=new Uint8ClampedArray(e.height*e.width*4);for(let t=0;ts.processBufferViewImage(e)).then(e=>{f.bufferView=e})):void 0!==p.toDataURL?f.uri=p.toDataURL(i):c.push(v(p,i).then(e=>new FileReader().readAsDataURL(e)).then(e=>{f.uri=e}));let y=a.images.push(f)-1;return u[h]=y,y}throw Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(e){let t=this.json;t.samplers||(t.samplers=[]);let n={magFilter:l[e.magFilter],minFilter:l[e.minFilter],wrapS:l[e.wrapS],wrapT:l[e.wrapT]};return t.samplers.push(n)-1}async processTextureAsync(e){let t=this.options,n=this.cache,i=this.json;if(n.textures.has(e))return n.textures.get(e);i.textures||(i.textures=[]),e instanceof r.FvD&&(e=await this.decompressTextureAsync(e,t.maxTextureSize));let s=e.userData.mimeType;"image/webp"===s&&(s="image/png");let o={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,s)};e.name&&(o.name=e.name),await this._invokeAllAsync(async function(t){t.writeTexture&&await t.writeTexture(e,o)});let a=i.textures.push(o)-1;return n.textures.set(e,a),a}async processMaterialAsync(e){let t=this.cache,n=this.json;if(t.materials.has(e))return t.materials.get(e);if(e.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;n.materials||(n.materials=[]);let i={pbrMetallicRoughness:{}};!0!==e.isMeshStandardMaterial&&!0!==e.isMeshBasicMaterial&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");let s=e.color.toArray().concat([e.opacity]);if(h(s,[1,1,1,1])||(i.pbrMetallicRoughness.baseColorFactor=s),e.isMeshStandardMaterial?(i.pbrMetallicRoughness.metallicFactor=e.metalness,i.pbrMetallicRoughness.roughnessFactor=e.roughness):(i.pbrMetallicRoughness.metallicFactor=0,i.pbrMetallicRoughness.roughnessFactor=1),e.metalnessMap||e.roughnessMap){let t=await this.buildMetalRoughTextureAsync(e.metalnessMap,e.roughnessMap),n={index:await this.processTextureAsync(t),texCoord:t.channel};this.applyTextureTransform(n,t),i.pbrMetallicRoughness.metallicRoughnessTexture=n}if(e.map){let t={index:await this.processTextureAsync(e.map),texCoord:e.map.channel};this.applyTextureTransform(t,e.map),i.pbrMetallicRoughness.baseColorTexture=t}if(e.emissive){let t=e.emissive;if(Math.max(t.r,t.g,t.b)>0&&(i.emissiveFactor=e.emissive.toArray()),e.emissiveMap){let t={index:await this.processTextureAsync(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(t,e.emissiveMap),i.emissiveTexture=t}}if(e.normalMap){let t={index:await this.processTextureAsync(e.normalMap),texCoord:e.normalMap.channel};e.normalScale&&1!==e.normalScale.x&&(t.scale=e.normalScale.x),this.applyTextureTransform(t,e.normalMap),i.normalTexture=t}if(e.aoMap){let t={index:await this.processTextureAsync(e.aoMap),texCoord:e.aoMap.channel};1!==e.aoMapIntensity&&(t.strength=e.aoMapIntensity),this.applyTextureTransform(t,e.aoMap),i.occlusionTexture=t}e.transparent?i.alphaMode="BLEND":e.alphaTest>0&&(i.alphaMode="MASK",i.alphaCutoff=e.alphaTest),e.side===r.$EB&&(i.doubleSided=!0),""!==e.name&&(i.name=e.name),this.serializeUserData(e,i),await this._invokeAllAsync(async function(t){t.writeMaterialAsync&&await t.writeMaterialAsync(e,i)});let o=n.materials.push(i)-1;return t.materials.set(e,o),o}async processMeshAsync(e){let t;let n=this.cache,i=this.json,a=[e.geometry.uuid];if(Array.isArray(e.material))for(let t=0,n=e.material.length;t0){let t=[],r=[],i={};if(void 0!==e.morphTargetDictionary)for(let t in e.morphTargetDictionary)i[e.morphTargetDictionary[t]]=t;for(let s=0;s0&&(u.extras={},u.extras.targetNames=r)}let y=Array.isArray(e.material);if(y&&0===c.groups.length)return null;let b=!1;if(y&&null===c.index){let e=[];for(let t=0,n=c.attributes.position.count;t0&&(r.targets=p),null!==c.index){let t=this.getUID(c.index);(void 0!==w[e].start||void 0!==w[e].count)&&(t+=":"+w[e].start+":"+w[e].count),n.attributes.has(t)?r.indices=n.attributes.get(t):(r.indices=this.processAccessor(c.index,c,w[e].start,w[e].count),n.attributes.set(t,r.indices)),null===r.indices&&delete r.indices}let i=await this.processMaterialAsync(g[w[e].materialIndex]);null!==i&&(r.material=i),f.push(r)}!0===b&&c.setIndex(null),u.primitives=f,i.meshes||(i.meshes=[]),await this._invokeAllAsync(function(t){t.writeMesh&&t.writeMesh(e,u)});let k=i.meshes.push(u)-1;return n.meshes.set(l,k),k}detectMeshQuantization(e,t){let n;if(this.extensionsUsed[a])return;switch(t.array.constructor){case Int8Array:n="byte";break;case Uint8Array:n="unsigned byte";break;case Int16Array:n="short";break;case Uint16Array:n="unsigned short";break;default:return}t.normalized&&(n+=" normalized");let r=e.split("_",1)[0];i[r]&&i[r].includes(n)&&(this.extensionsUsed[a]=!0,this.extensionsRequired[a]=!0)}processCamera(e){let t=this.json;t.cameras||(t.cameras=[]);let n=e.isOrthographicCamera,i={type:n?"orthographic":"perspective"};return n?i.orthographic={xmag:2*e.right,ymag:2*e.top,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:i.perspective={aspectRatio:e.aspect,yfov:r.cj9.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},""!==e.name&&(i.name=e.type),t.cameras.push(i)-1}processAnimation(e,t){let n=this.json,i=this.nodeMap;n.animations||(n.animations=[]);let o=(e=s.Utils.mergeMorphTargetTracks(e.clone(),t)).tracks,a=[],l=[];for(let e=0;e0){let t=[];for(let r=0,i=e.children.length;r0&&(i.children=t)}await this._invokeAllAsync(function(t){t.writeNode&&t.writeNode(e,i)});let s=t.nodes.push(i)-1;return r.set(e,s),s}async processSceneAsync(e){let t=this.json,n=this.options;t.scenes||(t.scenes=[],t.scene=0);let r={};""!==e.name&&(r.name=e.name),t.scenes.push(r);let i=[];for(let t=0,r=e.children.length;t0&&(r.nodes=i),this.serializeUserData(e,r)}async processObjectsAsync(e){let t=new r.Z58;t.name="AuxScene";for(let n=0;n0&&await this.processObjectsAsync(n);for(let e=0;e0&&(s.range=e.distance)):e.isSpotLight&&(s.type="spot",e.distance>0&&(s.range=e.distance),s.spot={},s.spot.innerConeAngle=(1-e.penumbra)*e.angle,s.spot.outerConeAngle=e.angle),void 0!==e.decay&&2!==e.decay&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),e.target&&(e.target.parent!==e||0!==e.target.position.x||0!==e.target.position.y||-1!==e.target.position.z)&&console.warn("THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."),i[this.name]||(r.extensions=r.extensions||{},r.extensions[this.name]={lights:[]},i[this.name]=!0);let o=r.extensions[this.name].lights;o.push(s),t.extensions=t.extensions||{},t.extensions[this.name]={light:o.length-1}}}class b{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}async writeMaterialAsync(e,t){if(!e.isMeshBasicMaterial)return;let n=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},n[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}}class g{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||0===e.clearcoat)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.clearcoatFactor=e.clearcoat,e.clearcoatMap){let t={index:await n.processTextureAsync(e.clearcoatMap),texCoord:e.clearcoatMap.channel};n.applyTextureTransform(t,e.clearcoatMap),i.clearcoatTexture=t}if(i.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){let t={index:await n.processTextureAsync(e.clearcoatRoughnessMap),texCoord:e.clearcoatRoughnessMap.channel};n.applyTextureTransform(t,e.clearcoatRoughnessMap),i.clearcoatRoughnessTexture=t}if(e.clearcoatNormalMap){let t={index:await n.processTextureAsync(e.clearcoatNormalMap),texCoord:e.clearcoatNormalMap.channel};1!==e.clearcoatNormalScale.x&&(t.scale=e.clearcoatNormalScale.x),n.applyTextureTransform(t,e.clearcoatNormalMap),i.clearcoatNormalTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class w{constructor(e){this.writer=e,this.name="KHR_materials_dispersion"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||0===e.dispersion)return;let n=this.writer.extensionsUsed,r={};r.dispersion=e.dispersion,t.extensions=t.extensions||{},t.extensions[this.name]=r,n[this.name]=!0}}class k{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||0===e.iridescence)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.iridescenceFactor=e.iridescence,e.iridescenceMap){let t={index:await n.processTextureAsync(e.iridescenceMap),texCoord:e.iridescenceMap.channel};n.applyTextureTransform(t,e.iridescenceMap),i.iridescenceTexture=t}if(i.iridescenceIor=e.iridescenceIOR,i.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],i.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){let t={index:await n.processTextureAsync(e.iridescenceThicknessMap),texCoord:e.iridescenceThicknessMap.channel};n.applyTextureTransform(t,e.iridescenceThicknessMap),i.iridescenceThicknessTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class T{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.transmissionFactor=e.transmission,e.transmissionMap){let t={index:await n.processTextureAsync(e.transmissionMap),texCoord:e.transmissionMap.channel};n.applyTextureTransform(t,e.transmissionMap),i.transmissionTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class A{constructor(e){this.writer=e,this.name="KHR_materials_volume"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.thicknessFactor=e.thickness,e.thicknessMap){let t={index:await n.processTextureAsync(e.thicknessMap),texCoord:e.thicknessMap.channel};n.applyTextureTransform(t,e.thicknessMap),i.thicknessTexture=t}e.attenuationDistance!==1/0&&(i.attenuationDistance=e.attenuationDistance),i.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class x{constructor(e){this.writer=e,this.name="KHR_materials_ior"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||1.5===e.ior)return;let n=this.writer.extensionsUsed,r={};r.ior=e.ior,t.extensions=t.extensions||{},t.extensions[this.name]=r,n[this.name]=!0}}class P{constructor(e){this.writer=e,this.name="KHR_materials_specular"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||1===e.specularIntensity&&e.specularColor.equals(u)&&!e.specularIntensityMap&&!e.specularColorMap)return;let n=this.writer,r=n.extensionsUsed,i={};if(e.specularIntensityMap){let t={index:await n.processTextureAsync(e.specularIntensityMap),texCoord:e.specularIntensityMap.channel};n.applyTextureTransform(t,e.specularIntensityMap),i.specularTexture=t}if(e.specularColorMap){let t={index:await n.processTextureAsync(e.specularColorMap),texCoord:e.specularColorMap.channel};n.applyTextureTransform(t,e.specularColorMap),i.specularColorTexture=t}i.specularFactor=e.specularIntensity,i.specularColorFactor=e.specularColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class R{constructor(e){this.writer=e,this.name="KHR_materials_sheen"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||0==e.sheen)return;let n=this.writer,r=n.extensionsUsed,i={};if(e.sheenRoughnessMap){let t={index:await n.processTextureAsync(e.sheenRoughnessMap),texCoord:e.sheenRoughnessMap.channel};n.applyTextureTransform(t,e.sheenRoughnessMap),i.sheenRoughnessTexture=t}if(e.sheenColorMap){let t={index:await n.processTextureAsync(e.sheenColorMap),texCoord:e.sheenColorMap.channel};n.applyTextureTransform(t,e.sheenColorMap),i.sheenColorTexture=t}i.sheenRoughnessFactor=e.sheenRoughness,i.sheenColorFactor=e.sheenColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class S{constructor(e){this.writer=e,this.name="KHR_materials_anisotropy"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||0==e.anisotropy)return;let n=this.writer,r=n.extensionsUsed,i={};if(e.anisotropyMap){let t={index:await n.processTextureAsync(e.anisotropyMap)};n.applyTextureTransform(t,e.anisotropyMap),i.anisotropyTexture=t}i.anisotropyStrength=e.anisotropy,i.anisotropyRotation=e.anisotropyRotation,t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class E{constructor(e){this.writer=e,this.name="KHR_materials_emissive_strength"}async writeMaterialAsync(e,t){if(!e.isMeshStandardMaterial||1===e.emissiveIntensity)return;let n=this.writer.extensionsUsed,r={};r.emissiveStrength=e.emissiveIntensity,t.extensions=t.extensions||{},t.extensions[this.name]=r,n[this.name]=!0}}class O{constructor(e){this.writer=e,this.name="EXT_materials_bump"}async writeMaterialAsync(e,t){if(!e.isMeshStandardMaterial||1===e.bumpScale&&!e.bumpMap)return;let n=this.writer,r=n.extensionsUsed,i={};if(e.bumpMap){let t={index:await n.processTextureAsync(e.bumpMap),texCoord:e.bumpMap.channel};n.applyTextureTransform(t,e.bumpMap),i.bumpTexture=t}i.bumpFactor=e.bumpScale,t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}}class M{constructor(e){this.writer=e,this.name="EXT_mesh_gpu_instancing"}writeNode(e,t){if(!e.isInstancedMesh)return;let n=this.writer,i=new Float32Array(3*e.count),s=new Float32Array(4*e.count),o=new Float32Array(3*e.count),a=new r.kn4,l=new r.Pq0,c=new r.PTz,u=new r.Pq0;for(let t=0;tMath.abs(e.times[0]-t))return 0;i[0]=t,i.set(e.times,1),s.set(o.evaluate(t),0),s.set(e.values,r),n=0}else if(t>e.times[e.times.length-1]){if(.001>Math.abs(e.times[e.times.length-1]-t))return e.times.length-1;i[i.length-1]=t,i.set(e.times,0),s.set(e.values,0),s.set(o.evaluate(t),e.values.length),n=i.length-1}else for(let a=0;aMath.abs(e.times[a]-t))return a;if(e.times[a]t){i.set(e.times.slice(0,a+1),0),i[a+1]=t,i.set(e.times.slice(a+1),a+2),s.set(e.values.slice(0,(a+1)*r),0),s.set(o.evaluate(t),(a+1)*r),s.set(e.values.slice((a+1)*r),(a+2)*r),n=a+1;break}}return e.times=i,e.values=s,n},mergeMorphTargetTracks:function(e,t){let n=[],i={},s=e.tracks;for(let e=0;e=2.0 are supported."));return}let l=new eT(i,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e=0&&void 0===o[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}l.setExtensions(s),l.setPlugins(o),l.parse(n,r)}parseAsync(e,t){let n=this;return new Promise(function(r,i){n.parse(e,t,r,i)})}}function C(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}let j={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class B{constructor(e){this.parser=e,this.name=j.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n=0))return null;throw Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures")}return t.loadTextureImage(e,i.source,s)}}class Y{constructor(e){this.parser=e,this.name=j.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let s=i.extensions[t],o=r.images[s.source],a=n.textureLoader;if(o.uri){let e=n.options.manager.getHandler(o.uri);null!==e&&(a=e)}return this.detectSupport().then(function(i){if(i)return n.loadTextureImage(e,s.source,a);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){let t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}})),this.isSupported}}class Q{constructor(e){this.parser=e,this.name=j.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let s=i.extensions[t],o=r.images[s.source],a=n.textureLoader;if(o.uri){let e=n.options.manager.getHandler(o.uri);null!==e&&(a=e)}return this.detectSupport().then(function(i){if(i)return n.loadTextureImage(e,s.source,a);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){let t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(1===t.height)}})),this.isSupported}}class J{constructor(e){this.name=j.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(!n.extensions||!n.extensions[this.name])return null;{let e=n.extensions[this.name],r=this.parser.getDependency("buffer",e.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(!(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0))return null;throw Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files")}return r.then(function(t){let n=e.byteOffset||0,r=e.byteLength||0,s=e.count,o=e.byteStride,a=new Uint8Array(t,n,r);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(s,o,a,e.mode,e.filter).then(function(e){return e.buffer}):i.ready.then(function(){let t=new ArrayBuffer(s*o);return i.decodeGltfBuffer(new Uint8Array(t),s,o,a,e.mode,e.filter),t})})}}}class Z{constructor(e){this.name=j.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||void 0===n.mesh)return null;for(let e of t.meshes[n.mesh].primitives)if(e.mode!==el.TRIANGLES&&e.mode!==el.TRIANGLE_STRIP&&e.mode!==el.TRIANGLE_FAN&&void 0!==e.mode)return null;let i=n.extensions[this.name].attributes,s=[],o={};for(let e in i)s.push(this.parser.getDependency("accessor",i[e]).then(t=>(o[e]=t,o[e])));return s.length<1?null:(s.push(this.parser.createNodeMesh(e)),Promise.all(s).then(e=>{let t=e.pop(),n=t.isGroup?t.children:[t],i=e[0].count,s=[];for(let e of n){let t=new r.kn4,n=new r.Pq0,a=new r.PTz,l=new r.Pq0(1,1,1),c=new r.ZLX(e.geometry,e.material,i);for(let e=0;e-1)?e.match(/Firefox\/([0-9]+)\./)[1]:-1}"undefined"==typeof createImageBitmap||n&&i<17||s&&o<98?this.textureLoader=new r.Tap(this.options.manager):this.textureLoader=new r.Kzg(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new r.Y9S(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,r=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(e){return e._markDefs&&e._markDefs()}),Promise.all(this._invokeAll(function(e){return e.beforeRoot&&e.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(t){let s={scene:t[0][r.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:r.asset,parser:n,userData:{}};return ey(i,s,r),eb(s,r),Promise.all(n._invokeAll(function(e){return e.afterRoot&&e.afterRoot(s)})).then(function(){for(let e of s.scenes)e.updateMatrixWorld();e(s)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,r=t.length;n{let n=this.associations.get(e);for(let[r,s]of(null!=n&&this.associations.set(t,n),e.children.entries()))i(s,t.children[r])};return i(n,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n=2&&o.setY(t,f[e*l+1]),l>=3&&o.setZ(t,f[e*l+2]),l>=4&&o.setW(t,f[e*l+3]),l>=5)throw Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}o.normalized=d}return o})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e].source,i=t.images[r],s=this.textureLoader;if(i.uri){let e=n.manager.getHandler(i.uri);null!==e&&(s=e)}return this.loadTextureImage(e,r,s)}loadTextureImage(e,t,n){let i=this,s=this.json,o=s.textures[e],a=s.images[t],l=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[l])return this.textureCache[l];let c=this.loadImageSource(t,n).then(function(t){t.flipY=!1,t.name=o.name||a.name||"",""===t.name&&"string"==typeof a.uri&&!1===a.uri.startsWith("data:image/")&&(t.name=a.uri);let n=(s.samplers||{})[o.sampler]||{};return t.magFilter=eu[n.magFilter]||r.k6q,t.minFilter=eu[n.minFilter]||r.$_I,t.wrapS=eh[n.wrapS]||r.GJx,t.wrapT=eh[n.wrapT]||r.GJx,t.generateMipmaps=!t.isCompressedTexture&&t.minFilter!==r.hxR&&t.minFilter!==r.k6q,i.associations.set(t,{textures:e}),t}).catch(function(){return null});return this.textureCache[l]=c,c}loadImageSource(e,t){let n=this.json,i=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then(e=>e.clone());let s=n.images[e],o=self.URL||self.webkitURL,a=s.uri||"",l=!1;if(void 0!==s.bufferView)a=this.getDependency("bufferView",s.bufferView).then(function(e){l=!0;let t=new Blob([e],{type:s.mimeType});return a=o.createObjectURL(t)});else if(void 0===s.uri)throw Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let c=Promise.resolve(a).then(function(e){return new Promise(function(n,s){let o=n;!0===t.isImageBitmapLoader&&(o=function(e){let t=new r.gPd(e);t.needsUpdate=!0,n(t)}),t.load(r.r6x.resolveURL(e,i.path),o,void 0,s)})}).then(function(e){var t;return!0===l&&o.revokeObjectURL(a),eb(e,s),e.userData.mimeType=s.mimeType||((t=s.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":t.search(/\.ktx2($|\?)/i)>0||0===t.search(/^data\:image\/ktx2/)?"image/ktx2":"image/png"),e}).catch(function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),e});return this.sourceCache[e]=c,c}assignTexture(e,t,n,r){let i=this;return this.getDependency("texture",n.index).then(function(s){if(!s)return null;if(void 0!==n.texCoord&&n.texCoord>0&&((s=s.clone()).channel=n.texCoord),i.extensions[j.KHR_TEXTURE_TRANSFORM]){let e=void 0!==n.extensions?n.extensions[j.KHR_TEXTURE_TRANSFORM]:void 0;if(e){let t=i.associations.get(s);s=i.extensions[j.KHR_TEXTURE_TRANSFORM].extendTexture(s,e),i.associations.set(s,t)}}return void 0!==r&&(s.colorSpace=r),e[t]=s,s})}assignFinalMaterial(e){let t=e.geometry,n=e.material,i=void 0===t.attributes.tangent,s=void 0!==t.attributes.color,o=void 0===t.attributes.normal;if(e.isPoints){let e="PointsMaterial:"+n.uuid,t=this.cache.get(e);t||(t=new r.BH$,r.imn.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){let e="LineBasicMaterial:"+n.uuid,t=this.cache.get(e);t||(t=new r.mrM,r.imn.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,this.cache.add(e,t)),n=t}if(i||s||o){let e="ClonedMaterial:"+n.uuid+":";i&&(e+="derivative-tangents:"),s&&(e+="vertex-colors:"),o&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=n.clone(),s&&(t.vertexColors=!0),o&&(t.flatShading=!0),i&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}e.material=n}getMaterialType(){return r._4j}loadMaterial(e){let t;let n=this,i=this.json,s=this.extensions,o=i.materials[e],a={},l=o.extensions||{},c=[];if(l[j.KHR_MATERIALS_UNLIT]){let e=s[j.KHR_MATERIALS_UNLIT];t=e.getMaterialType(),c.push(e.extendParams(a,o,n))}else{let i=o.pbrMetallicRoughness||{};if(a.color=new r.Q1f(1,1,1),a.opacity=1,Array.isArray(i.baseColorFactor)){let e=i.baseColorFactor;a.color.setRGB(e[0],e[1],e[2],r.Zr2),a.opacity=e[3]}void 0!==i.baseColorTexture&&c.push(n.assignTexture(a,"map",i.baseColorTexture,r.er$)),a.metalness=void 0!==i.metallicFactor?i.metallicFactor:1,a.roughness=void 0!==i.roughnessFactor?i.roughnessFactor:1,void 0!==i.metallicRoughnessTexture&&(c.push(n.assignTexture(a,"metalnessMap",i.metallicRoughnessTexture)),c.push(n.assignTexture(a,"roughnessMap",i.metallicRoughnessTexture))),t=this._invokeOne(function(t){return t.getMaterialType&&t.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,a)})))}!0===o.doubleSided&&(a.side=r.$EB);let u=o.alphaMode||em.OPAQUE;if(u===em.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,u===em.MASK&&(a.alphaTest=void 0!==o.alphaCutoff?o.alphaCutoff:.5)),void 0!==o.normalTexture&&t!==r.V9B&&(c.push(n.assignTexture(a,"normalMap",o.normalTexture)),a.normalScale=new r.I9Y(1,1),void 0!==o.normalTexture.scale)){let e=o.normalTexture.scale;a.normalScale.set(e,e)}if(void 0!==o.occlusionTexture&&t!==r.V9B&&(c.push(n.assignTexture(a,"aoMap",o.occlusionTexture)),void 0!==o.occlusionTexture.strength&&(a.aoMapIntensity=o.occlusionTexture.strength)),void 0!==o.emissiveFactor&&t!==r.V9B){let e=o.emissiveFactor;a.emissive=new r.Q1f().setRGB(e[0],e[1],e[2],r.Zr2)}return void 0!==o.emissiveTexture&&t!==r.V9B&&c.push(n.assignTexture(a,"emissiveMap",o.emissiveTexture,r.er$)),Promise.all(c).then(function(){let r=new t(a);return o.name&&(r.name=o.name),eb(r,o),n.associations.set(r,{materials:e}),o.extensions&&ey(s,r,o),r})}createUniqueName(e){let t=r.Nwf.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,n=this.extensions,i=this.primitiveCache,s=[];for(let o=0,a=e.length;o0&&function(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let n=0,r=t.weights.length;n1?new r.YJl:1===t.length?t[0]:new r.B69)!==t[0])for(let e=0,n=t.length;e{let t=new Map;for(let[e,n]of i.associations)(e instanceof r.imn||e instanceof r.gPd)&&t.set(e,n);return e.traverse(e=>{let n=i.associations.get(e);null!=n&&t.set(e,n)}),t})(s),s})}_createAnimationTracks(e,t,n,i,s){let o;let a=[],l=e.name?e.name:e.uuid,c=[];switch(ed[s.path]===ed.weights?e.traverse(function(e){e.morphTargetInfluences&&c.push(e.name?e.name:e.uuid)}):c.push(l),ed[s.path]){case ed.weights:o=r.Hit;break;case ed.rotation:o=r.MBL;break;case ed.position:case ed.scale:o=r.RiT;break;default:o=1===n.itemSize?r.Hit:r.RiT}let u=void 0!==i.interpolation?ev[i.interpolation]:r.PJ3,h=this._getArrayFromAccessor(n);for(let e=0,n=c.length;e{n.d(t,{m:()=>c});var r=n("./src/model/ball.ts"),i=n("./src/view/tablegeometry.ts"),s=n("./node_modules/three/build/three.module.js"),o=n("./src/utils/utils.ts"),a=n("./src/model/physics/constants.ts");function l(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var c=/*#__PURE__*/function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t)}return e=[{key:"jitter",value:function(e){return(0,o.ld)(e.clone().add(new s.Pq0(t.noise*(Math.random()-.5),t.noise*(Math.random()-.5),0)))}},{key:"cueBall",value:function(e){return new r.c(t.jitter(e),0xfaebd7)}},{key:"diamond",value:function(){var e=new s.Pq0(i.P.tableX/2,0,0),n=[];return n.push(t.cueBall(t.spot)),n.push(new r.c(t.jitter(e),0xe0de36)),e.add(t.diagonal),n.push(new r.c(t.jitter(e),0xff9d00)),e.sub(t.across),n.push(new r.c(t.jitter(e),5380369)),e.add(t.diagonal),n.push(new r.c(t.jitter(e),5853696)),e.sub(t.across),n.push(new r.c(t.jitter(e),0xff0000)),e.addScaledVector(t.across,2),n.push(new r.c(t.jitter(e),328965)),e.add(t.diagonal).sub(t.across),n.push(new r.c(t.jitter(e),685250)),e.sub(t.across),n.push(new r.c(t.jitter(e),553728)),e.add(t.diagonal),n.push(new r.c(t.jitter(e),4063388)),n}},{key:"triangle",value:function(){var e=t.trianglePositions(),n=t.cueBall(t.spot),i=e.map(function(e){return new r.c(t.jitter(e))});return i.unshift(n),i.slice(0,5)}},{key:"trianglePositions",value:function(){var e=[],t=new s.Pq0(i.P.X/2,0,0);return e.push((0,o.t6)(t)),t.add(this.diagonal),e.push((0,o.t6)(t)),t.sub(this.across),e.push((0,o.t6)(t)),t.add(this.diagonal),e.push((0,o.t6)(t)),t.sub(this.across),e.push((0,o.t6)(t)),t.addScaledVector(this.across,2),e.push((0,o.t6)(t)),t.add(this.diagonal),e.push((0,o.t6)(t)),t.sub(this.across),e.push((0,o.t6)(t)),t.sub(this.across),e.push((0,o.t6)(t)),t.sub(this.across),e.push((0,o.t6)(t)),t.add(this.diagonal).sub(this.across),e.push((0,o.t6)(t)),t.add(this.across),e.push((0,o.t6)(t)),t.add(this.across),e.push((0,o.t6)(t)),t.add(this.across),e.push((0,o.t6)(t)),t.add(this.across),e.push((0,o.t6)(t)),e}},{key:"rerack",value:function(e,n){var i=t.trianglePositions(),s=i.shift();n.balls.filter(function(e){return e!==n.cueball}).filter(function(t){return t!==e}).forEach(function(e){e.pos.copy(t.jitter(i.shift())),e.state=r.U.Stationary}),n.overlapsAny(e.pos,e)&&e.pos.copy(s),n.overlapsAny(n.cueball.pos)&&n.cueball.pos.copy(t.spot)}},{key:"three",value:function(){var e=[],n=i.P.X/2,o=i.P.Y/4;return e.push(t.cueBall(t.jitter(new s.Pq0(-n,-o,0)))),e.push(new r.c(t.jitter(new s.Pq0(-n,0,0)),0xe0de36)),e.push(new r.c(t.jitter(new s.Pq0(n,0,0)),0xff0000)),e}},{key:"snooker",value:function(){var e=[],n=i.P.Y/4;e.push(t.cueBall(t.jitter(new s.Pq0(t.baulk,-(.5*n),0))));var o=t.snookerColourPositions();return e.push(new r.c(t.jitter(o[0]),0xeede36)),e.push(new r.c(t.jitter(o[1]),824932)),e.push(new r.c(t.jitter(o[2]),0xbd723a)),e.push(new r.c(t.jitter(o[3]),558062)),e.push(new r.c(t.jitter(o[4]),0xffaacc)),e.push(new r.c(t.jitter(o[5]),65793)),t.trianglePositions().slice(0,15).forEach(function(n){e.push(new r.c(t.jitter(n.add(t.down)),0xee0000))}),e}},{key:"snookerColourPositions",value:function(){var e=i.P.X/2,n=i.P.X-2*i.P.X/11,r=[];return r.push(new s.Pq0(t.baulk,-t.sixth,0)),r.push(new s.Pq0(t.baulk,t.sixth,0)),r.push(new s.Pq0(t.baulk,0,0)),r.push(new s.Pq0(0,0,0)),r.push(new s.Pq0(e,0,0)),r.push(new s.Pq0(n,0,0)),r}}],function(e,t){for(var n=0;n{n.d(t,{k:()=>a});var r=n("./src/model/ball.ts"),i=n("./src/view/tablegeometry.ts"),s=n("./src/model/physics/constants.ts"),o=n("./src/utils/rack.ts"),a=/*#__PURE__*/function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t)}return e=[{key:"respot",value:function(e,n){var i=o.m.snookerColourPositions();return i.push(i[e.id-1]),i.reverse(),i.some(function(t){return!n.overlapsAny(t,e)&&(e.pos.copy(t),e.state=r.U.Stationary,!0)})||t.respotBehind(i[0],e,n),e}},{key:"respotBehind",value:function(e,t,n){for(var o=e.clone();o.x-i.P.tableX&&n.overlapsAny(o,t);)o.x-=s.R/8;t.pos.copy(o),t.state=r.U.Stationary}},{key:"closest",value:function(e,t){var n=t.filter(function(e){return e.onTable()}).filter(function(t){return t!==e});if(0!==n.length){var r=function(t){return e.pos.distanceTo(t.pos)};return n.reduce(function(e,t){return r(e){n.d(t,{Dz:()=>p,KM:()=>l,ld:()=>v,rq:()=>f,t6:()=>o,up:()=>s,v_:()=>i,xb:()=>u});var r=n("./node_modules/three/build/three.module.js"),i=new r.Pq0(0,0,0),s=new r.Pq0(0,0,1);function o(e){return new r.Pq0(e.x,e.y,e.z)}var a=new r.Pq0;function l(e){return a.copy(s).cross(e)}var c=new r.Pq0;function u(e){return c.copy(e).normalize()}var h=new r.Pq0;function f(e,t){return 0>=h.copy(e).add(t).dot(e)}function p(e){return new r.Pq0(1,0,0).applyAxisAngle(s,e)}function d(e){return Math.sign(e)*Math.floor((Math.abs(e)+Number.EPSILON)*1e4)/1e4}function v(e){return e.x=d(e.x),e.y=d(e.y),e.z=d(e.z),e}},"./src/view/assets.ts":(e,t,n)=>{n.d(t,{s:()=>m});var r=n("./src/controller/rules/rulefactory.ts"),i=n("./src/utils/gltf.ts"),s=n("./node_modules/three/build/three.module.js");function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var a=/*#__PURE__*/function(){var e;function t(e){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),o(this,"listener",void 0),o(this,"audioLoader",void 0),o(this,"ballcollision",void 0),o(this,"cue",void 0),o(this,"cushion",void 0),o(this,"pot",void 0),o(this,"success",void 0),o(this,"lastOutcomeTime",0),o(this,"loadAssets",void 0),this.loadAssets=e,e&&(this.listener=new s.Pf$,this.audioLoader=new s.Am1,this.ballcollision=new s.fP5(this.listener),this.load("sounds/ballcollision.ogg",this.ballcollision),this.cue=new s.fP5(this.listener),this.load("sounds/cue.ogg",this.cue),this.cushion=new s.fP5(this.listener),this.load("sounds/cushion.ogg",this.cushion),this.pot=new s.fP5(this.listener),this.load("sounds/pot.ogg",this.pot),this.success=new s.fP5(this.listener),this.load("sounds/success.ogg",this.success))}return e=[{key:"addCameraToListener",value:function(e){e.add(this.listener)}},{key:"load",value:function(e,t){this.audioLoader.load(e,function(e){t.setBuffer(e),t.setLoop(!1)},function(e){},function(e){})}},{key:"play",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(this.loadAssets){var r,i,o=s.UtX.getContext();if((null==o?void 0:o.state)==="suspended"){(null===(i=navigator)||void 0===i?void 0:null===(r=i.userActivation)||void 0===r?void 0:r.hasBeenActive)&&o.resume();return}e.setVolume(t),e.isPlaying&&e.stop(),e.play(s.cj9.randFloat(0,.01)),e.setDetune(n)}}},{key:"outcomeToSound",value:function(e){"Collision"===e.type&&this.play(this.ballcollision,e.incidentSpeed/80,5*e.incidentSpeed),"Pot"===e.type&&this.play(this.pot,e.incidentSpeed/10,-1e3+10*e.incidentSpeed),"Cushion"===e.type&&this.play(this.cushion,e.incidentSpeed/70),"Hit"===e.type&&this.play(this.cue,e.incidentSpeed/30)}},{key:"processOutcomes",value:function(e){var t=this;e.every(function(e){return!(e.timestamp>t.lastOutcomeTime)||(t.lastOutcomeTime=e.timestamp,t.outcomeToSound(e),!1)})}},{key:"playNotify",value:function(){this.play(this.pot,1)}},{key:"playSuccess",value:function(e){this.play(this.success,.1,100*e-2200)}}],function(e,t){for(var n=0;n2&&void 0!==arguments[2]?arguments[2]:this.cloth;this.cylinder(e.pos,e.radius,.75*u.R/.5,t,n).position.setZ(-(.25*u.R)/.5/2)}},{key:"cylinder",value:function(e,t,n,r,i){var o=new s.Ho_(t,t,n,16),a=new s.eaF(o,i);return a.position.copy(e),a.geometry.applyMatrix4(new s.kn4().identity().makeRotationAxis(new s.Pq0(1,0,0),Math.PI/2)),r.add(a),a}},{key:"addCushions",value:function(e,t){var n=10*u.R/.5;this.plane(new s.Pq0(0,0,-u.R-n/2),2*l.P.X,2*l.P.Y,n,e,this.cloth);var r=1*u.R/.5,i=.75*u.R/.5,o=-(.25*u.R)/.5/2,a=l.P.X,h=l.P.Y,f=Math.abs(c.f.pockets.pocketNW.knuckleNE.pos.x-c.f.pockets.pocketN.knuckleNW.pos.x),p=Math.abs(c.f.pockets.pocketNW.knuckleSW.pos.y-c.f.pockets.pocketSW.knuckleNW.pos.y);t||(f=2*l.P.Y,p=2*l.P.Y+4*u.R),this.plane(new s.Pq0(a+r/2,0,o),r,p,i,e),this.plane(new s.Pq0(-a-r/2,0,o),r,p,i,e),this.plane(new s.Pq0(-a/2,h+r/2,o),f,r,i,e),this.plane(new s.Pq0(-a/2,-h-r/2,o),f,r,i,e),this.plane(new s.Pq0(a/2,h+r/2,o),f,r,i,e),this.plane(new s.Pq0(a/2,-h-r/2,o),f,r,i,e)}},{key:"plane",value:function(e,t,n,r,i){var o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:this.cushion,a=new s.iNn(t,n,r),l=new s.eaF(a,o);l.receiveShadow=!0,l.position.copy(e),i.add(l)}}],function(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:"",t=new n(e);return t.creatLocal(),t}}],e&&d(n.prototype,e),t&&d(n,t),n}()},"./src/view/cameratop.ts":(e,t,n)=>{n.d(t,{v:()=>a});var r=n("./node_modules/three/build/three.module.js"),i=n("./src/view/tablegeometry.ts"),s=n("./src/model/physics/constants.ts");function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var a=/*#__PURE__*/function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t)}return e=[{key:"viewPoint",value:function(e,n){var o=t.zoomFactor/(2*Math.tan(n*Math.PI/360));if(e>this.portrait){var a=e>t.aspectLimit?2.75*i.P.tableY:2.4*i.P.tableX/e;return new r.Pq0(0,-.01*s.R,o*a)}var l=e>1/t.aspectLimit?4.9*i.P.tableY:1.35*i.P.tableX/e;return new r.Pq0(-.01*s.R,0,o*l)}}],function(e,t){for(var n=0;n{n.d(t,{s:()=>f});var r=n("./src/view/tablegeometry.ts"),i=n("./src/utils/utils.ts"),s=n("./src/events/aimevent.ts"),o=n("./src/model/ball.ts"),a=n("./src/model/physics/physics.ts"),l=n("./src/view/cuemesh.ts"),c=n("./node_modules/three/build/three.module.js"),u=n("./src/model/physics/constants.ts");function h(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var f=/*#__PURE__*/function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),h(this,"mesh",void 0),h(this,"helperMesh",void 0),h(this,"placerMesh",void 0),h(this,"offCenterLimit",.3),h(this,"maxPower",150*u.R),h(this,"t",0),h(this,"aimInputs",void 0),h(this,"aim",new s.w),h(this,"length",1*r.P.tableX),this.mesh=l.l.createCue(.05*u.R/.5,.15*u.R/.5,this.length),this.helperMesh=l.l.createHelper(),this.placerMesh=l.l.createPlacer()}return e=[{key:"rotateAim",value:function(e,t){this.aim.angle=this.aim.angle+e,this.mesh.rotation.z=this.aim.angle,this.helperMesh.rotation.z=this.aim.angle,this.aimInputs.showOverlap(),this.avoidCueTouchingOtherBall(t)}},{key:"adjustPower",value:function(e){this.aim.power=Math.min(this.maxPower,this.aim.power+e),this.updateAimInput()}},{key:"setPower",value:function(e){this.aim.power=e*this.maxPower}},{key:"hit",value:function(e){var t=this.aim;this.t=0,e.state=o.U.Sliding,e.vel.copy((0,i.Dz)(t.angle).multiplyScalar(t.power)),e.rvel.copy((0,a.t6)(t.offset,e.vel))}},{key:"aimAtNext",value:function(e,t){if(t){var n=(0,i.xb)(t.pos.clone().sub(e.pos));this.aim.angle=Math.atan2(n.y,n.x)}}},{key:"adjustSpin",value:function(e,t){var n=this.aim.offset.clone().clone().add(e);this.setSpin(n,t)}},{key:"setSpin",value:function(e,t){e.length()>this.offCenterLimit&&e.normalize().multiplyScalar(this.offCenterLimit),this.aim.offset.copy(e),this.avoidCueTouchingOtherBall(t),this.updateAimInput()}},{key:"avoidCueTouchingOtherBall",value:function(e){for(var t=0;t++<20&&this.intersectsAnything(e);)this.aim.offset.y+=.1,this.aim.offset.length()>this.offCenterLimit&&this.aim.offset.normalize().multiplyScalar(this.offCenterLimit);t>1&&this.updateAimInput()}},{key:"updateAimInput",value:function(){var e,t,n;null===(e=this.aimInputs)||void 0===e||e.updateVisualState(this.aim.offset.x,this.aim.offset.y),null===(t=this.aimInputs)||void 0===t||t.updatePowerSlider(this.aim.power/this.maxPower),null===(n=this.aimInputs)||void 0===n||n.showOverlap()}},{key:"moveTo",value:function(e){this.aim.pos.copy(e),this.mesh.rotation.z=this.aim.angle,this.helperMesh.rotation.z=this.aim.angle;var t=this.spinOffset(),n=(Math.sin(this.t+Math.PI/2)-1)*2*u.R*(this.aim.power/this.maxPower),r=(0,i.Dz)(this.aim.angle).clone().multiplyScalar(n);this.mesh.position.copy(e.clone().add(t).add(r)),this.helperMesh.position.copy(e),this.placerMesh.position.copy(e),this.placerMesh.rotation.z=this.t}},{key:"update",value:function(e){this.t+=e,this.moveTo(this.aim.pos)}},{key:"placeBallMode",value:function(){this.mesh.visible=!1,this.placerMesh.visible=!0,this.aim.angle=0}},{key:"aimMode",value:function(){this.mesh.visible=!0,this.placerMesh.visible=!1}},{key:"spinOffset",value:function(){return(0,i.KM)((0,i.Dz)(this.aim.angle)).multiplyScalar(2*this.aim.offset.x*u.R).setZ(2*this.aim.offset.y*u.R)}},{key:"intersectsAnything",value:function(e){var t=this.spinOffset(),n=e.cueball.pos.clone().add(t),r=(0,i.xb)((0,i.Dz)(this.aim.angle+Math.PI).setZ(.1)),s=new c.tBo(n,r),o=e.balls.map(function(e){return e.ballmesh.mesh});return e.mesh&&o.push(e.mesh),s.intersectObjects(o,!0).length>0}},{key:"showHelper",value:function(e){this.helperMesh.visible=e}},{key:"toggleHelper",value:function(){this.showHelper(!this.helperMesh.visible)}}],function(e,t){for(var n=0;n{n.d(t,{l:()=>a});var r=n("./src/model/physics/constants.ts"),i=n("./src/utils/utils.ts"),s=n("./node_modules/three/build/three.module.js");function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var a=/*#__PURE__*/function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t)}return e=[{key:"indicateValid",value:function(e){t.placermaterial.color.setHex(e?0xccffcc:0xff0000)}},{key:"createHelper",value:function(){var e=new s.Ho_(r.R,r.R,30*r.R/.5,12,1,!0),t=new s.eaF(e,this.helpermaterial);return t.geometry.applyMatrix4(new s.kn4().identity().makeRotationAxis(i.up,-Math.PI/2)).applyMatrix4(new s.kn4().identity().makeTranslation(15*r.R/.5,0,-(.01*r.R)/.5)),t.visible=!1,t.renderOrder=-1,t.material.depthTest=!1,t}},{key:"createPlacer",value:function(){var e=new s.Ho_(.01*r.R/.5,r.R,r.R,4),n=new s.eaF(e,t.placermaterial);return n.geometry.applyMatrix4(new s.kn4().identity().makeRotationAxis(new s.Pq0(1,0,0),-Math.PI/2)).applyMatrix4(new s.kn4().identity().makeTranslation(0,0,.7*r.R/.5)),n.visible=!1,n}},{key:"createCue",value:function(e,n,o){var a=new s.Ho_(e,n,o,11),l=new s.eaF(a,t.material);return l.castShadow=!1,l.geometry.applyMatrix4(new s.kn4().identity().makeRotationAxis(new s.Pq0(1,0,0),-.17)).applyMatrix4(new s.kn4().identity().makeRotationAxis(i.up,-Math.PI/2)).applyMatrix4(new s.kn4().identity().makeTranslation(-o/2-r.R,0,o/2*.16918234906699603+.25*r.R)),l}}],function(e,t){for(var n=0;n{n.d(t,{f:()=>c});var r=n("./node_modules/three/build/three.module.js"),i=n("./src/model/physics/knuckle.ts"),s=n("./src/model/physics/pocket.ts"),o=n("./src/view/tablegeometry.ts"),a=n("./src/model/physics/constants.ts");function l(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var c=/*#__PURE__*/function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t)}return e=[{key:"scaleToRadius",value:function(e){t.PX=o.P.tableX+1.6*e,t.PY=o.P.tableY+1.6*e,t.knuckleInset=1.6*e/.5,t.knuckleRadius=.31*e/.5,t.middleKnuckleInset=1.385*e/.5,t.middleKnuckleRadius=.2*e/.5,t.cornerRadius=1.1*e/.5,t.middleRadius=.9*e/.5,t.pocketLayout(e),t.enumerateCenters(),t.enumerateKnuckles()}},{key:"enumerateKnuckles",value:function(){t.knuckles=[t.pockets.pocketNW.knuckleNE,t.pockets.pocketNW.knuckleSW,t.pockets.pocketN.knuckleNW,t.pockets.pocketN.knuckleNE,t.pockets.pocketS.knuckleSW,t.pockets.pocketS.knuckleSE,t.pockets.pocketNE.knuckleNW,t.pockets.pocketNE.knuckleSE,t.pockets.pocketSE.knuckleNE,t.pockets.pocketSE.knuckleSW,t.pockets.pocketSW.knuckleSE,t.pockets.pocketSW.knuckleNW]}},{key:"enumerateCenters",value:function(){t.pocketCenters=[t.pockets.pocketNW.pocket,t.pockets.pocketSW.pocket,t.pockets.pocketN.pocket,t.pockets.pocketS.pocket,t.pockets.pocketNE.pocket,t.pockets.pocketSE.pocket]}},{key:"pocketLayout",value:function(e){t.pockets={pocketNW:{pocket:new s.Z(new r.Pq0(-t.PX,t.PY,0),t.cornerRadius),knuckleNE:new i.O(new r.Pq0(-o.P.X+t.knuckleInset,o.P.Y+t.knuckleRadius,0),t.knuckleRadius),knuckleSW:new i.O(new r.Pq0(-o.P.X-t.knuckleRadius,o.P.Y-t.knuckleInset,0),t.knuckleRadius)},pocketN:{pocket:new s.Z(new r.Pq0(0,t.PY+.7*e/.5,0),t.middleRadius),knuckleNE:new i.O(new r.Pq0(t.middleKnuckleInset,o.P.Y+t.middleKnuckleRadius,0),t.middleKnuckleRadius),knuckleNW:new i.O(new r.Pq0(-t.middleKnuckleInset,o.P.Y+t.middleKnuckleRadius,0),t.middleKnuckleRadius)},pocketS:{pocket:new s.Z(new r.Pq0(0,-t.PY-.7*e/.5,0),t.middleRadius),knuckleSE:new i.O(new r.Pq0(t.middleKnuckleInset,-o.P.Y-t.middleKnuckleRadius,0),t.middleKnuckleRadius),knuckleSW:new i.O(new r.Pq0(-t.middleKnuckleInset,-o.P.Y-t.middleKnuckleRadius,0),t.middleKnuckleRadius)},pocketNE:{pocket:new s.Z(new r.Pq0(t.PX,t.PY,0),t.cornerRadius),knuckleNW:new i.O(new r.Pq0(o.P.X-t.knuckleInset,o.P.Y+t.knuckleRadius,0),t.knuckleRadius),knuckleSE:new i.O(new r.Pq0(o.P.X+t.knuckleRadius,o.P.Y-t.knuckleInset,0),t.knuckleRadius)},pocketSE:{pocket:new s.Z(new r.Pq0(t.PX,-t.PY,0),t.cornerRadius),knuckleNE:new i.O(new r.Pq0(o.P.X+t.knuckleRadius,-o.P.Y+t.knuckleInset,0),t.knuckleRadius),knuckleSW:new i.O(new r.Pq0(o.P.X-t.knuckleInset,-o.P.Y-t.knuckleRadius,0),t.knuckleRadius)},pocketSW:{pocket:new s.Z(new r.Pq0(-t.PX,-t.PY,0),t.cornerRadius),knuckleSE:new i.O(new r.Pq0(-o.P.X+t.knuckleInset,-o.P.Y-t.knuckleRadius,0),t.knuckleRadius),knuckleNW:new i.O(new r.Pq0(-o.P.X-t.knuckleRadius,-o.P.Y+t.knuckleInset,0),t.knuckleRadius)}}}}],function(e,t){for(var n=0;n{n.d(t,{r:()=>s});var r=n("./src/model/physics/constants.ts");function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var s=/*#__PURE__*/function(){var e;function t(e){var n,s;!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),i(this,"style",void 0),i(this,"notify",void 0),this.notify=null!=e?e:function(){},this.style=null!==(s=null===(n=document.getElementById("constants"))||void 0===n?void 0:n.style)&&void 0!==s?s:{},this.initialiseSlider("R",r.R,r.jG),this.initialiseSlider("m",r.m,r.Qg),this.initialiseSlider("e",r.e,r.cM),this.initialiseSlider("mu",r.mu,r.xO),this.initialiseSlider("muS",r.gf,r.Ys),this.initialiseSlider("muC",r.gT,r.kM),this.initialiseSlider("rho",r.kL,r.Wv)}return e=[{key:"toggleVisibility",value:function(){this.style.visibility="visible"===this.style.visibility?"hidden":"visible"}},{key:"getInputElement",value:function(e){var t;return null!==(t=document.getElementById(e))&&void 0!==t?t:{}}},{key:"initialiseSlider",value:function(e,t,n){var r=this,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,s=this.getInputElement(e);s.step="0.001",s.min="0.01",s.max="".concat(i),s.value=t,this.showValue(e,t),s.oninput=function(t){var i=parseFloat(t.target.value);n(i),r.showValue(e,i),r.notify()}}},{key:"showValue",value:function(e,t){var n=document.querySelector("label[for=".concat(e,"]"));n&&(n.innerHTML="".concat(e,"=").concat(t))}}],function(e,t){for(var n=0;n{n.d(t,{P:()=>s});var r=n("./src/model/physics/constants.ts");function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var s=/*#__PURE__*/function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t)}return e=[{key:"scaleToRadius",value:function(e){t.tableX=43*e,t.tableY=21*e,t.X=t.tableX+e,t.Y=t.tableY+e}}],function(e,t){for(var n=0;n{e(e.s="./src/index.ts")}]); \ No newline at end of file diff --git a/dist/mathaven.js b/dist/mathaven.js index 7dede7a8..6c7544ee 100644 --- a/dist/mathaven.js +++ b/dist/mathaven.js @@ -1 +1 @@ -"use strict";(self.webpackChunkbilliards=self.webpackChunkbilliards||[]).push([[893],{"./src/mathaven.ts":(t,e,n)=>{var i=n("./src/model/physics/claude/constants.ts"),o=n("./src/model/physics/claude/qwen.ts");function r(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function a(t,e,n){return(a="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){var i=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=s(t)););return t}(t,e);if(i){var o=Object.getOwnPropertyDescriptor(i,e);return o.get?o.get.call(n||t):o.value}})(t,e,n||t)}function s(t){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function u(t,e){return(u=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function c(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(c=function(){return!!t})()}var l=/*#__PURE__*/function(t){var e;function n(){var t,e,i,o;return!function(t,e){if(!(t instanceof e))throw TypeError("Cannot call a class as a function")}(this,n),e=n,i=arguments,e=s(e),r(t=(o=c()?Reflect.construct(e,i||[],s(this).constructor):e.apply(this,i))&&("object"==(o&&"undefined"!=typeof Symbol&&o.constructor===Symbol?"symbol":typeof o)||"function"==typeof o)?o:function(t){if(void 0===t)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(this),"h",[]),r(t,"extractValues",function(e){return t.h.map(e).map(function(t){return null!=t?t:0})}),t}return!function(t,e){if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&u(t,e)}(n,t),e=[{key:"updateSingleStep",value:function(t){a(s(n.prototype),"updateSingleStep",this).call(this,t),this.h.push(function(t){for(var e=1;e0&&void 0!==arguments[0]?arguments[0]:2,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Math.PI/4,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2*t/i.R,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1.5*t/i.R,r=new l(i.M,i.R,i.ee,i.o,i._);try{r.solvePaper(t,e,n,o)}catch(t){console.error(t)}var a=r.extractValues,s=a(function(t){return t.P});f.title.text="Figure.12 Slip–impulse curves \nfor V0 = 2 m/s, α = 45◦,ωS0 = 2V0/R, and ωT0 = 1.5V0/R \n
(s and φ are for the slip at the cushion, \nand sʹ and φʹ are for the slip at the table)",window.Plotly.newPlot("mathaven-impulse",[v(s,a(function(t){return t.s}),"s",p(0)),v(s,a(function(t){return t.φ}),"φ",p(1)),v(s,a(function(t){return t.sʹ}),"s'",p(2)),v(s,a(function(t){return t.φʹ}),"φʹ",p(3)),v(s,a(function(t){return t.WzI}),"WzI",p(4)),v(s,a(function(t){return t.P}),"P",p(5))],f,h),f.title.text="";var u=a(function(t){return t.i});window.Plotly.newPlot("mathaven-vel",[v(u,a(function(t){return t.vy}),"vy",p(0)),v(u,a(function(t){return t.vx}),"vx",p(1)),v(u,a(function(t){return t.ωx*i.R}),"ωx",p(2)),v(u,a(function(t){return t.ωy*i.R}),"ωy",p(3)),v(u,a(function(t){return t.ωz*i.R}),"ωz",p(4)),v(u,a(function(t){return t.WzI}),"WzI",p(5)),v(u,a(function(t){return t.P}),"P",p(6))],f,h)}}],function(t,e){for(var n=0;n3&&void 0!==arguments[3]?arguments[3]:function(t){return 0},r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:function(t){return t/i.R},a=[],s=[],u=[],c=-1;c<=2;c++){var l=[],y=[];u=[];for(var d=1;d<90;d+=9){u.push(d);var b=this.getFinalState(1,Math.PI/180*d,o(c),r(c));l.push(b.speed),y.push(b.beta)}a.push(l),s.push(y)}var g=u;f.title.text=n,window.Plotly.newPlot(t,[v(g,a[0],"k=-1",p(0)),v(g,a[1],"k=0",p(1)),v(g,a[2],"k=1",p(2)),v(g,a[3],"k=2",p(3))],f,h),window.Plotly.newPlot(e,[v(g,s[0],"k=-1",p(0)),v(g,s[1],"k=0",p(1)),v(g,s[2],"k=1",p(2)),v(g,s[3],"k=2",p(3))],f,h)}}],function(t,e){for(var n=0;nFigure.9 Rebound speed and rebound angle versus incident angle
\n for different topspins of the ball, ωT0 = kV0/R and V0 = 1 m/s with no sidespin"),new d().plot("mathaven-figure10-speed","mathaven-figure10-angle","Figure.10 Rebound speed and rebound angle versus incident angle
\nfor different sidespins of the ball,ωS0 = kV0/R and V0 = 1 m/s with the ball rolling (ωT0 = V0/R)",function(t){return t/i.R},function(t){return 1/i.R}),new w().plot()},"./src/model/physics/claude/constants.ts":(t,e,n)=>{n.d(e,{M:()=>i,R:()=>o,_:()=>s,ee:()=>r,o:()=>a});var i=.1406,o=.02625,r=.98,a=.212,s=.14},"./src/model/physics/claude/qwen.ts":(t,e,n)=>{n.d(e,{z:()=>r});var i=n("./src/model/physics/constants.ts");function o(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var r=/*#__PURE__*/function(){var t;function e(t,n,i,r,a){!function(t,e){if(!(t instanceof e))throw TypeError("Cannot call a class as a function")}(this,e),o(this,"P",0),o(this,"WzI",0),o(this,"vx",void 0),o(this,"vy",void 0),o(this,"ωx",void 0),o(this,"ωy",void 0),o(this,"ωz",void 0),o(this,"s",void 0),o(this,"φ",void 0),o(this,"sʹ",void 0),o(this,"φʹ",void 0),o(this,"i",0),o(this,"N",100),o(this,"M",void 0),o(this,"R",void 0),o(this,"μs",void 0),o(this,"μw",void 0),o(this,"ee",void 0),this.M=t,this.R=n,this.ee=i,this.μs=r,this.μw=a}return t=[{key:"updateSlipSpeedsAndAngles",value:function(){var t=this.R,e=this.vx+this.ωy*t*i.Z3-this.ωz*t*i.o5,n=-this.vy*i.Z3+this.ωx*t,o=this.vx-this.ωy*t,r=this.vy+this.ωx*t;this.s=Math.sqrt(Math.pow(e,2)+Math.pow(n,2)),this.φ=Math.atan2(n,e),this.φ<0&&(this.φ+=2*Math.PI),this.sʹ=Math.sqrt(Math.pow(o,2)+Math.pow(r,2)),this.φʹ=Math.atan2(r,o),this.φʹ<0&&(this.φʹ+=2*Math.PI)}},{key:"compressionPhase",value:function(){for(var t=Math.max(this.M*this.vy/this.N,.001);this.vy>0;)this.updateSingleStep(t)}},{key:"restitutionPhase",value:function(t){var e=Math.max(t/this.N,.001);for(this.WzI=0;this.WzI10*this.N)throw"Solution not found"}},{key:"updateVelocity",value:function(t){var e=this.μs,n=this.μw,o=this.M;this.vx-=1/o*(n*Math.cos(this.φ)+e*Math.cos(this.φʹ)*(i.Z3+n*Math.sin(this.φ)*i.o5))*t,this.vy-=1/o*(i.o5-n*i.Z3*Math.sin(this.φ)+e*Math.sin(this.φʹ)*(i.Z3+n*Math.sin(this.φ)*i.o5))*t}},{key:"updateAngularVelocity",value:function(t){var e=this.μs,n=this.μw,o=this.M,r=this.R;this.ωx+=-(5/(2*o*r))*(n*Math.sin(this.φ)+e*Math.sin(this.φʹ)*(i.Z3+n*Math.sin(this.φ)*i.o5))*t,this.ωy+=-(5/(2*o*r))*(n*Math.cos(this.φ)*i.Z3-e*Math.cos(this.φʹ)*(i.Z3+n*Math.sin(this.φ)*i.o5))*t,this.ωz+=5/(2*o*r)*(n*Math.cos(this.φ)*i.o5)*t}},{key:"updateWorkDone",value:function(t){var e=t*Math.abs(this.vy);this.WzI+=e,this.P+=t}},{key:"solvePaper",value:function(t,e,n,i){this.solve(t*Math.cos(e),t*Math.sin(e),-i*Math.sin(e),i*Math.cos(e),n)}},{key:"solve",value:function(t,e,n,i,o){this.vx=t,this.vy=e,this.ωx=n,this.ωy=i,this.ωz=o,this.WzI=0,this.P=0,this.i=0,this.compressionPhase();var r=this.WzI-(1-this.ee*this.ee)*this.WzI;this.restitutionPhase(r)}}],function(t,e){for(var n=0;n{n.d(e,{I:()=>r,Mz:()=>i,Qg:()=>g,R:()=>f,Wv:()=>M,Ys:()=>m,Z3:()=>v,cM:()=>k,e:()=>p,g:()=>a,gT:()=>c,gf:()=>u,jG:()=>b,kL:()=>l,kM:()=>P,m:()=>h,mu:()=>s,o5:()=>y,x3:()=>o,xO:()=>w});var i,o,r,a=9.8,s=.00985,u=.16,c=.8,l=.034,h=.23,f=.03275,p=.86,v=.4,y=Math.sqrt(21)/5;function d(){i=s*h*a*2/3*l,o=7/(5*Math.sqrt(2))*f*s*h*a,r=.4*h*f*f}function b(t){f=t,d()}function g(t){h=t,d()}function w(t){s=t,d()}function M(t){l=t,d()}function m(t){u=t}function k(t){p=t}function P(t){c=t}d()}},t=>{t(t.s="./src/mathaven.ts")}]); \ No newline at end of file +"use strict";(self.webpackChunkbilliards=self.webpackChunkbilliards||[]).push([[893],{"./src/diagram/constants.ts":(t,e,n)=>{n.d(e,{M:()=>i,R:()=>o,_:()=>s,ee:()=>r,o:()=>a});var i=.1406,o=.02625,r=.98,a=.212,s=.14},"./src/mathaven.ts":(t,e,n)=>{var i=n("./src/diagram/constants.ts"),o=n("./src/model/physics/mathaven.ts");function r(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function a(t,e,n){return(a="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){var i=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=s(t)););return t}(t,e);if(i){var o=Object.getOwnPropertyDescriptor(i,e);return o.get?o.get.call(n||t):o.value}})(t,e,n||t)}function s(t){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function u(t,e){return(u=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function l(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(l=function(){return!!t})()}var c=/*#__PURE__*/function(t){var e;function n(){var t,e,i,o;return!function(t,e){if(!(t instanceof e))throw TypeError("Cannot call a class as a function")}(this,n),e=n,i=arguments,e=s(e),r(t=(o=l()?Reflect.construct(e,i||[],s(this).constructor):e.apply(this,i))&&("object"==(o&&"undefined"!=typeof Symbol&&o.constructor===Symbol?"symbol":typeof o)||"function"==typeof o)?o:function(t){if(void 0===t)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(this),"h",[]),r(t,"extractValues",function(e){return t.h.map(e).map(function(t){return null!=t?t:0})}),t}return!function(t,e){if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&u(t,e)}(n,t),e=[{key:"updateSingleStep",value:function(t){a(s(n.prototype),"updateSingleStep",this).call(this,t),this.h.push(function(t){for(var e=1;e0&&void 0!==arguments[0]?arguments[0]:2,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Math.PI/4,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2*t/i.R,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1.5*t/i.R,r=new c(i.M,i.R,i.ee,i.o,i._);try{r.solvePaper(t,e,n,o)}catch(t){console.error(t)}var a=r.extractValues,s=a(function(t){return t.P});f.title.text="Figure.12 Slip–impulse curves \nfor V0 = 2 m/s, α = 45◦,ωS0 = 2V0/R, and ωT0 = 1.5V0/R \n
(s and φ are for the slip at the cushion, \nand sʹ and φʹ are for the slip at the table)",window.Plotly.newPlot("mathaven-impulse",[v(s,a(function(t){return t.s}),"s",p(0)),v(s,a(function(t){return t.φ}),"φ",p(1)),v(s,a(function(t){return t.sʹ}),"s'",p(2)),v(s,a(function(t){return t.φʹ}),"φʹ",p(3)),v(s,a(function(t){return t.WzI}),"WzI",p(4)),v(s,a(function(t){return t.P}),"P",p(5))],f,h),f.title.text="";var u=a(function(t){return t.i});window.Plotly.newPlot("mathaven-vel",[v(u,a(function(t){return t.vy}),"vy",p(0)),v(u,a(function(t){return t.vx}),"vx",p(1)),v(u,a(function(t){return t.ωx*i.R}),"ωx",p(2)),v(u,a(function(t){return t.ωy*i.R}),"ωy",p(3)),v(u,a(function(t){return t.ωz*i.R}),"ωz",p(4)),v(u,a(function(t){return t.WzI}),"WzI",p(5)),v(u,a(function(t){return t.P}),"P",p(6))],f,h)}}],function(t,e){for(var n=0;n3&&void 0!==arguments[3]?arguments[3]:function(t){return 0},r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:function(t){return t/i.R},a=[],s=[],u=[],l=-1;l<=2;l++){var c=[],y=[];u=[];for(var d=1;d<90;d+=9){u.push(d);var b=this.getFinalState(1,Math.PI/180*d,o(l),r(l));c.push(b.speed),y.push(b.beta)}a.push(c),s.push(y)}var g=u;f.title.text=n,window.Plotly.newPlot(t,[v(g,a[0],"k=-1",p(0)),v(g,a[1],"k=0",p(1)),v(g,a[2],"k=1",p(2)),v(g,a[3],"k=2",p(3))],f,h),window.Plotly.newPlot(e,[v(g,s[0],"k=-1",p(0)),v(g,s[1],"k=0",p(1)),v(g,s[2],"k=1",p(2)),v(g,s[3],"k=2",p(3))],f,h)}}],function(t,e){for(var n=0;nfrom https://billiards.colostate.edu/technical_proofs/new/TP_A-14.pdf ",window.Plotly.newPlot("collision-throw",[v(a,t[0],"k=-1",p(0)),v(a,t[1],"k=0",p(1)),v(a,t[2],"k=1",p(2)),v(a,t[3],"k=2",p(3))],f,h)}}],function(t,e){for(var n=0;nFigure.9 Rebound speed and rebound angle versus incident angle
\n for different topspins of the ball, ωT0 = kV0/R and V0 = 1 m/s with no sidespin"),new d().plot("mathaven-figure10-speed","mathaven-figure10-angle","Figure.10 Rebound speed and rebound angle versus incident angle
\nfor different sidespins of the ball,ωS0 = kV0/R and V0 = 1 m/s with the ball rolling (ωT0 = V0/R)",function(t){return t/i.R},function(t){return 1/i.R}),new w().plot()},"./src/model/physics/constants.ts":(t,e,n)=>{n.d(e,{I:()=>r,Mz:()=>i,Qg:()=>g,R:()=>f,Wv:()=>m,Ys:()=>M,Z3:()=>v,cM:()=>P,e:()=>p,g:()=>a,gT:()=>l,gf:()=>u,jG:()=>b,kL:()=>c,kM:()=>k,m:()=>h,mu:()=>s,o5:()=>y,x3:()=>o,xO:()=>w});var i,o,r,a=9.8,s=.00985,u=.16,l=.8,c=.034,h=.23,f=.03275,p=.86,v=.4,y=Math.sqrt(21)/5;function d(){i=s*h*a*2/3*c,o=7/(5*Math.sqrt(2))*f*s*h*a,r=.4*h*f*f}function b(t){f=t,d()}function g(t){h=t,d()}function w(t){s=t,d()}function m(t){c=t,d()}function M(t){u=t}function P(t){p=t}function k(t){l=t}d()},"./src/model/physics/mathaven.ts":(t,e,n)=>{n.d(e,{z:()=>r});var i=n("./src/model/physics/constants.ts");function o(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var r=/*#__PURE__*/function(){var t;function e(t,n,i,r,a){!function(t,e){if(!(t instanceof e))throw TypeError("Cannot call a class as a function")}(this,e),o(this,"P",0),o(this,"WzI",0),o(this,"vx",void 0),o(this,"vy",void 0),o(this,"ωx",void 0),o(this,"ωy",void 0),o(this,"ωz",void 0),o(this,"s",void 0),o(this,"φ",void 0),o(this,"sʹ",void 0),o(this,"φʹ",void 0),o(this,"i",0),o(this,"N",100),o(this,"M",void 0),o(this,"R",void 0),o(this,"μs",void 0),o(this,"μw",void 0),o(this,"ee",void 0),this.M=t,this.R=n,this.ee=i,this.μs=r,this.μw=a}return t=[{key:"updateSlipSpeedsAndAngles",value:function(){var t=this.R,e=this.vx+this.ωy*t*i.Z3-this.ωz*t*i.o5,n=-this.vy*i.Z3+this.ωx*t,o=this.vx-this.ωy*t,r=this.vy+this.ωx*t;this.s=Math.sqrt(Math.pow(e,2)+Math.pow(n,2)),this.φ=Math.atan2(n,e),this.φ<0&&(this.φ+=2*Math.PI),this.sʹ=Math.sqrt(Math.pow(o,2)+Math.pow(r,2)),this.φʹ=Math.atan2(r,o),this.φʹ<0&&(this.φʹ+=2*Math.PI)}},{key:"compressionPhase",value:function(){for(var t=Math.max(this.M*this.vy/this.N,.001);this.vy>0;)this.updateSingleStep(t)}},{key:"restitutionPhase",value:function(t){var e=Math.max(t/this.N,.001);for(this.WzI=0;this.WzI10*this.N)throw"Solution not found"}},{key:"updateVelocity",value:function(t){var e=this.μs,n=this.μw,o=this.M;this.vx-=1/o*(n*Math.cos(this.φ)+e*Math.cos(this.φʹ)*(i.Z3+n*Math.sin(this.φ)*i.o5))*t,this.vy-=1/o*(i.o5-n*i.Z3*Math.sin(this.φ)+e*Math.sin(this.φʹ)*(i.Z3+n*Math.sin(this.φ)*i.o5))*t}},{key:"updateAngularVelocity",value:function(t){var e=this.μs,n=this.μw,o=this.M,r=this.R;this.ωx+=-(5/(2*o*r))*(n*Math.sin(this.φ)+e*Math.sin(this.φʹ)*(i.Z3+n*Math.sin(this.φ)*i.o5))*t,this.ωy+=-(5/(2*o*r))*(n*Math.cos(this.φ)*i.Z3-e*Math.cos(this.φʹ)*(i.Z3+n*Math.sin(this.φ)*i.o5))*t,this.ωz+=5/(2*o*r)*(n*Math.cos(this.φ)*i.o5)*t}},{key:"updateWorkDone",value:function(t){var e=t*Math.abs(this.vy);this.WzI+=e,this.P+=t}},{key:"solvePaper",value:function(t,e,n,i){this.solve(t*Math.cos(e),t*Math.sin(e),-i*Math.sin(e),i*Math.cos(e),n)}},{key:"solve",value:function(t,e,n,i,o){this.vx=t,this.vy=e,this.ωx=n,this.ωy=i,this.ωz=o,this.WzI=0,this.P=0,this.i=0,this.compressionPhase();var r=this.WzI-(1-this.ee*this.ee)*this.WzI;this.restitutionPhase(r)}}],function(t,e){for(var n=0;n{t(t.s="./src/mathaven.ts")}]); \ No newline at end of file diff --git a/src/model/physics/claude/constants.ts b/src/diagram/constants.ts similarity index 100% rename from src/model/physics/claude/constants.ts rename to src/diagram/constants.ts diff --git a/src/model/physics/claude/historymathaven.ts b/src/diagram/historymathaven.ts similarity index 87% rename from src/model/physics/claude/historymathaven.ts rename to src/diagram/historymathaven.ts index 8171531b..eb1e6b50 100644 --- a/src/model/physics/claude/historymathaven.ts +++ b/src/diagram/historymathaven.ts @@ -1,4 +1,4 @@ -import { Mathaven } from "./qwen"; +import { Mathaven } from "../model/physics/mathaven"; export class HistoryMathaven extends Mathaven { readonly h: Array> = []; diff --git a/src/diagram/impulseplot.ts b/src/diagram/impulseplot.ts index 22b3ddb4..f5a4e6ab 100644 --- a/src/diagram/impulseplot.ts +++ b/src/diagram/impulseplot.ts @@ -1,5 +1,5 @@ -import { ee, M, R, μs, μw } from "../model/physics/claude/constants"; -import { HistoryMathaven } from "../model/physics/claude/historymathaven"; +import { ee, M, R, μs, μw } from "./constants"; +import { HistoryMathaven } from "./historymathaven"; import { config, color, createTrace, layout } from "./plotlyconfig"; export class ImpulsePlot { diff --git a/src/diagram/reboundplot.ts b/src/diagram/reboundplot.ts index 89d12902..d66cb234 100644 --- a/src/diagram/reboundplot.ts +++ b/src/diagram/reboundplot.ts @@ -1,5 +1,5 @@ -import { ee, M, R, μs, μw } from "../model/physics/claude/constants"; -import { Mathaven } from "../model/physics/claude/qwen"; +import { ee, M, R, μs, μw } from "./constants"; +import { Mathaven } from "../model/physics/mathaven"; import { config, color, createTrace, layout } from "./plotlyconfig"; export class ReboundPlot { diff --git a/src/diagram/throwplot.ts b/src/diagram/throwplot.ts index 5b58ebfe..9e3c3b31 100644 --- a/src/diagram/throwplot.ts +++ b/src/diagram/throwplot.ts @@ -24,7 +24,7 @@ export class ThrowPlot { const x = deg - layout.title.text = "Throw effect" + layout.title.text = "Throw effect (WIP)
from https://billiards.colostate.edu/technical_proofs/new/TP_A-14.pdf " window.Plotly.newPlot("collision-throw", [ createTrace(x, angles[0], 'k=-1', color(0)), diff --git a/src/mathaven.ts b/src/mathaven.ts index 5e6ebb99..57094bd2 100644 --- a/src/mathaven.ts +++ b/src/mathaven.ts @@ -1,7 +1,7 @@ import { ImpulsePlot } from "./diagram/impulseplot"; import { ReboundPlot } from "./diagram/reboundplot"; import { ThrowPlot } from "./diagram/throwplot"; -import { R } from "./model/physics/claude/constants"; +import { R } from "./diagram/constants"; declare global { interface Window { diff --git a/src/model/physics/claude/qwen.ts b/src/model/physics/mathaven.ts similarity index 98% rename from src/model/physics/claude/qwen.ts rename to src/model/physics/mathaven.ts index 63355980..fd643467 100644 --- a/src/model/physics/claude/qwen.ts +++ b/src/model/physics/mathaven.ts @@ -1,4 +1,4 @@ -import { cosθ, sinθ } from "../constants"; +import { cosθ, sinθ } from "./constants"; export class Mathaven { // work done diff --git a/src/model/physics/physics.ts b/src/model/physics/physics.ts index 5f21e332..61fd57b9 100644 --- a/src/model/physics/physics.ts +++ b/src/model/physics/physics.ts @@ -1,8 +1,8 @@ import { Vector3 } from "three" import { norm, upCross, up } from "../../utils/utils" import { muS, muC, g, m, Mz, Mxy, R, I, e } from "./constants" -import { Mathaven } from "./claude/qwen" -import { ee, μs, μw } from "./claude/constants" +import { Mathaven } from "./mathaven" +import { ee, μs, μw } from "../../diagram/constants" export function surfaceVelocity(v, w) { return surfaceVelocityFull(v, w).setZ(0)