diff --git a/.gitattributes b/.gitattributes index a6344aac8c09253b3b630fb776ae94478aa0275b..5472131e8a1dee26ee1859bafcdf26e0c7a83665 100644 --- a/.gitattributes +++ b/.gitattributes @@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text *.zip filter=lfs diff=lfs merge=lfs -text *.zst filter=lfs diff=lfs merge=lfs -text *tfevents* filter=lfs diff=lfs merge=lfs -text +*.glb filter=lfs diff=lfs merge=lfs -text diff --git a/AsyncTasksManager.js b/AsyncTasksManager.js new file mode 100644 index 0000000000000000000000000000000000000000..0152b6aac71bb203fb2c05da6d922ca5bbc95b8b --- /dev/null +++ b/AsyncTasksManager.js @@ -0,0 +1,5 @@ +var gdjs;(function(i){class l{constructor(){this.tasksWithCallback=new Array}processTasks(e){for(let s=0;s{n.error(`A promise error has not been handled, this should never happen! +If you are using JavaScript promises in an asynchronous action, make sure to add a .catch(). +Otherwise, report this as a bug on the GDevelop forums! +${s?"The following error was thrown: "+s:""}`)}).then(s=>(this.isResolved=!0,s))}update(){return this.isResolved}}i.PromiseTask=h;class k extends t{constructor(){super(...arguments);this.isResolved=!1}resolve(){this.isResolved=!0}update(){return this.isResolved}}i.ManuallyResolvableTask=k})(gdjs||(gdjs={})); +//# sourceMappingURL=AsyncTasksManager.js.map diff --git a/CustomRuntimeObject.js b/CustomRuntimeObject.js new file mode 100644 index 0000000000000000000000000000000000000000..9529eb41d815cbe2692704525d26503907ec9747 --- /dev/null +++ b/CustomRuntimeObject.js @@ -0,0 +1,2 @@ +var gdjs;(function(r){const o=new r.Logger("CustomRuntimeObject");class h extends r.RuntimeObject{constructor(t,e){super(t,e);this._isUntransformedHitBoxesDirty=!0;this._untransformedHitBoxes=[];this._unrotatedAABB={min:[0,0],max:[0,0]};this._innerArea=null;this._isInnerAreaFollowingParentSize=!1;this._scaleX=1;this._scaleY=1;this._flippedX=!1;this._flippedY=!1;this.opacity=255;this._customCenter=null;this._localTransformation=new r.AffineTransformation;this._localInverseTransformation=new r.AffineTransformation;this._isLocalTransformationDirty=!0;this._type=e.type,this._instanceContainer=new r.CustomRuntimeObjectInstanceContainer(t,this),this._renderer=this._createRender(),this._initializeFromObjectData(e)}_initializeFromObjectData(t){const e=this._runtimeScene.getGame().getEventsBasedObjectData(t.type);if(!e){o.error(`A CustomRuntimeObject was initialized (or re-initialized) from object data referring to an non existing events based object data with type "${t.type}".`);return}this._isInnerAreaFollowingParentSize=e.isInnerAreaFollowingParentSize,e.instances.length>0&&(this._innerArea||(this._innerArea={min:[0,0,0],max:[0,0,0]}),this._innerArea.min[0]=e.areaMinX,this._innerArea.min[1]=e.areaMinY,this._innerArea.min[2]=e.areaMinZ,this._innerArea.max[0]=e.areaMaxX,this._innerArea.max[1]=e.areaMaxY,this._innerArea.max[2]=e.areaMaxZ),this._instanceContainer.loadFrom(t,e)}reinitialize(t){super.reinitialize(t),this._initializeFromObjectData(t),this._reinitializeRenderer(),this.onCreated()}updateFromObjectData(t,e){const i=this.getAnimator();return i&&i.updateFromObjectData(t.animatable||[],e.animatable||[]),!0}extraInitializationFromInitialInstance(t){const e=this.getAnimator();if(t.numberProperties)for(let i=0,n=t.numberProperties.length;i=this.hitBoxes.length&&this.hitBoxes.push(new r.Polygon);for(let i=0;i=this.hitBoxes[e].vertices.length&&this.hitBoxes[e].vertices.push([0,0]),t.transform(this._untransformedHitBoxes[e].vertices[i],this.hitBoxes[e].vertices[i]);this.hitBoxes[e].vertices.length=this._untransformedHitBoxes[e].vertices.length}}_updateUntransformedHitBoxes(){this._isUntransformedHitBoxesDirty=!1,this._untransformedHitBoxes.length=0;let t=Number.MAX_VALUE,e=Number.MAX_VALUE,i=-Number.MAX_VALUE,n=-Number.MAX_VALUE;for(const s of this._instanceContainer.getAdhocListOfAllInstances()){if(!s.isIncludedInParentCollisionMask())continue;Array.prototype.push.apply(this._untransformedHitBoxes,s.getHitBoxes());const a=s.getAABB();t=Math.min(t,a.min[0]),e=Math.min(e,a.min[1]),i=Math.max(i,a.max[0]),n=Math.max(n,a.max[1])}for(t===Number.MAX_VALUE&&(t=0,e=0,i=1,n=1),this._unrotatedAABB.min[0]=t,this._unrotatedAABB.min[1]=e,this._unrotatedAABB.max[0]=i,this._unrotatedAABB.max[1]=n;this.hitBoxes.length255&&(t=255),this.opacity=t,this.getRenderer().updateOpacity()}getOpacity(){return this.opacity}hide(t){t===void 0&&(t=!0),this.hidden=t,this.getRenderer().updateVisibility()}flipX(t){t!==this._flippedX&&(this._scaleX*=-1,this._flippedX=t,this.invalidateHitboxes(),this.getRenderer().update())}flipY(t){t!==this._flippedY&&(this._scaleY*=-1,this._flippedY=t,this.invalidateHitboxes(),this.getRenderer().update())}isFlippedX(){return this._flippedX}isFlippedY(){return this._flippedY}getAnimator(){return null}}r.CustomRuntimeObject=h,h.supportsReinitialization=!1})(gdjs||(gdjs={})); +//# sourceMappingURL=CustomRuntimeObject.js.map diff --git a/CustomRuntimeObject2D.js b/CustomRuntimeObject2D.js new file mode 100644 index 0000000000000000000000000000000000000000..9134f053e4d2333b1b70e14740d628c15468763d --- /dev/null +++ b/CustomRuntimeObject2D.js @@ -0,0 +1,2 @@ +var gdjs;(function(t){class n extends t.CustomRuntimeObject{constructor(e,r){super(e,r);this.getRenderer().reinitialize(this,e)}_createRender(){const e=this._runtimeScene;return new t.CustomRuntimeObject2DRenderer(this,this._instanceContainer,e)}_reinitializeRenderer(){this.getRenderer().reinitialize(this,this.getParent())}getRenderer(){return super.getRenderer()}getRendererObject(){return this.getRenderer().getRendererObject()}}t.CustomRuntimeObject2D=n})(gdjs||(gdjs={})); +//# sourceMappingURL=CustomRuntimeObject2D.js.map diff --git a/CustomRuntimeObjectInstanceContainer.js b/CustomRuntimeObjectInstanceContainer.js new file mode 100644 index 0000000000000000000000000000000000000000..e2cd2d60f71d6ff9ff84845300c3c54d03aab15f --- /dev/null +++ b/CustomRuntimeObjectInstanceContainer.js @@ -0,0 +1,2 @@ +var gdjs;(function(s){class l extends s.RuntimeInstanceContainer{constructor(t,n){super();this._isLoaded=!1;this._initialInnerArea=null;this._parent=t,this._customObject=n,this._runtimeScene=t.getScene(),this._debuggerRenderer=new s.DebuggerRenderer(this)}addLayer(t){const n=new s.RuntimeCustomObjectLayer(t,this);this._layers.put(t.name,n),this._orderedLayers.push(n)}createObject(t){const n=super.createObject(t);return this._customObject.onChildrenLocationChanged(),n}loadFrom(t,n){this._isLoaded&&this.onDestroyFromScene(this._parent),this._setOriginalInnerArea(n);for(let r=0,e=n.objects.length;r0)for(let r=0,e=n.layers.length;r0&&(t._initialInnerArea||(t._initialInnerArea={min:[t.areaMinX,t.areaMinY,t.areaMinZ],max:[t.areaMaxX,t.areaMaxY,t.areaMaxZ]}),this._initialInnerArea=t._initialInnerArea)}onDestroyFromScene(t){if(!this._isLoaded)return;const n=this.getAdhocListOfAllInstances();for(let r=0,e=n.length;r255&&(t=255),this.opacity=t,this._renderer.updateOpacity()}getOpacity(){return this.opacity}getString(){return this.getText()}setString(t){this.setText(t)}getText(){return this._str}setText(t){t!==this._str&&(this._str=t,this._renderer.updateString(),this._updateTextPosition())}getCharacterSize(){return this._characterSize}setCharacterSize(t){t<=1&&(t=1),this._characterSize=t,this._renderer.updateStyle()}setFontName(t){this._fontName=t,this._renderer.updateStyle()}isBold(){return this._bold}setBold(t){this._bold=t,this._renderer.updateStyle()}isItalic(){return this._italic}setItalic(t){this._italic=t,this._renderer.updateStyle()}getWidth(){return this._wrapping?this._wrappingWidth:this._renderer.getWidth()}getHeight(){return this._renderer.getHeight()}getScaleMean(){return(Math.abs(this._scaleX)+Math.abs(this._scaleY))/2}getScale(){const t=Math.abs(this._scaleX),s=Math.abs(this._scaleY);return t===s?t:Math.sqrt(t*s)}getScaleX(){return this._scaleX}getScaleY(){return this._scaleY}setScale(t){this._scaleX===t&&this._scaleY===t||(this._scaleX=t,this._scaleY=t,this._renderer.setScale(t),this.invalidateHitboxes())}setScaleX(t){this._scaleX!==t&&(this._scaleX=t,this._renderer.setScaleX(t),this.invalidateHitboxes())}setScaleY(t){this._scaleY!==t&&(this._scaleY=t,this._renderer.setScaleY(t),this.invalidateHitboxes())}setColor(t){const s=t.split(";");s.length<3||(this._color[0]=parseInt(s[0],10),this._color[1]=parseInt(s[1],10),this._color[2]=parseInt(s[2],10),this._useGradient=!1,this._renderer.updateStyle())}getColor(){return this._color[0]+";"+this._color[1]+";"+this._color[2]}setVerticalTextAlignment(t){this._verticalTextAlignment=t,this._renderer.updateStyle()}getVerticalTextAlignment(){return this._verticalTextAlignment}setTextAlignment(t){this._textAlign=t,this._renderer.updateStyle()}getTextAlignment(){return this._textAlign}isWrapping(){return this._wrapping}setWrapping(t){this._wrapping!==t&&(this._wrapping=t,this._renderer.updateStyle(),this.invalidateHitboxes())}getWrappingWidth(){return this._wrappingWidth}setWrappingWidth(t){t<=1&&(t=1),this._wrappingWidth!==t&&(this._wrappingWidth=t,this._wrapping&&(this._renderer.updateStyle(),this.invalidateHitboxes()))}setWidth(t){this.setWrappingWidth(t)}getDrawableY(){return this.getY()-(this._verticalTextAlignment==="center"?this.getHeight()/2:this._verticalTextAlignment==="bottom"?this.getHeight():0)}setOutline(t,s){const e=t.split(";");e.length<3||(this._outlineColor[0]=parseInt(e[0],10),this._outlineColor[1]=parseInt(e[1],10),this._outlineColor[2]=parseInt(e[2],10),this._outlineThickness=s,this._renderer.updateStyle())}isOutlineEnabled(){return this._isOutlineEnabled}setOutlineEnabled(t){this._isOutlineEnabled=t,this._renderer.updateStyle()}getOutlineThickness(){return this._outlineThickness}setOutlineThickness(t){this._outlineThickness=t,this._renderer.updateStyle()}setOutlineColor(t){this._outlineColor=r.rgbOrHexToRGBColor(t),this._renderer.updateStyle()}setShadow(t,s,e,i){const n=t.split(";");n.length<3||(this._shadowColor[0]=parseInt(n[0],10),this._shadowColor[1]=parseInt(n[1],10),this._shadowColor[2]=parseInt(n[2],10),this._shadowDistance=s,this._shadowBlur=e,this._shadowAngle=i,this._shadow=!0,this._renderer.updateStyle())}isShadowEnabled(){return this._shadow}showShadow(t){this._shadow=t,this._renderer.updateStyle()}getShadowOpacity(){return this._shadowOpacity}setShadowOpacity(t){this._shadowOpacity=t,this._renderer.updateStyle()}getShadowDistance(){return this._shadowDistance}setShadowDistance(t){this._shadowDistance=t,this._renderer.updateStyle()}getShadowAngle(){return this._shadowAngle}setShadowAngle(t){this._shadowAngle=t,this._renderer.updateStyle()}getShadowBlurRadius(){return this._shadowBlur}setShadowBlurRadius(t){this._shadowBlur=t,this._renderer.updateStyle()}setShadowColor(t){this._shadowColor=r.rgbOrHexToRGBColor(t),this._renderer.updateStyle()}setGradient(t,s,e,i,n){const o=s.split(";"),a=e.split(";"),h=i.split(";"),l=n.split(";");this._gradient=[],o.length==3&&this._gradient.push([parseInt(o[0],10),parseInt(o[1],10),parseInt(o[2],10)]),a.length==3&&this._gradient.push([parseInt(a[0],10),parseInt(a[1],10),parseInt(a[2],10)]),h.length==3&&this._gradient.push([parseInt(h[0],10),parseInt(h[1],10),parseInt(h[2],10)]),l.length==3&&this._gradient.push([parseInt(l[0],10),parseInt(l[1],10),parseInt(l[2],10)]),this._gradientType=t,this._useGradient=this._gradient.length>1,this._renderer.updateStyle()}getPadding(){return this._padding}setPadding(t){this._padding=t,this._renderer.updateStyle()}}r.TextRuntimeObject=d,r.registerObject("TextObject::Text",r.TextRuntimeObject)})(gdjs||(gdjs={})); +//# sourceMappingURL=textruntimeobject.js.map diff --git a/LICENSE.GDevelop.txt b/LICENSE.GDevelop.txt new file mode 100644 index 0000000000000000000000000000000000000000..b707a925c34caeb6240db8fe913186dd2f7cb2d8 --- /dev/null +++ b/LICENSE.GDevelop.txt @@ -0,0 +1,2 @@ +Part of this app is using the GDevelop game engine, which is licensed under the MIT license. +Find more information on https://gdevelop.io/. \ No newline at end of file diff --git a/Model3DManager.js b/Model3DManager.js new file mode 100644 index 0000000000000000000000000000000000000000..e2e5eeabf9fb866f38d5d4b5c44bb25aa0741e95 --- /dev/null +++ b/Model3DManager.js @@ -0,0 +1,2 @@ +var gdjs;(function(d){const a=new d.Logger("Model3DManager"),i=["model3D"];class l{constructor(r){this._loadedThreeModels=new d.ResourceCache;this._downloadedArrayBuffers=new d.ResourceCache;this._loader=null;this._dracoLoader=null;if(this._resourceLoader=r,typeof THREE!="undefined"){this._loader=new THREE_ADDONS.GLTFLoader,this._dracoLoader=new THREE_ADDONS.DRACOLoader,this._dracoLoader.setDecoderPath("./pixi-renderers/draco/gltf/"),this._loader.setDRACOLoader(this._dracoLoader);const e=new THREE.Group;e.add(new THREE.Mesh(new THREE.BoxGeometry(1,1,1),new THREE.MeshBasicMaterial({color:"#ff00ff"}))),this._invalidModel={scene:e,animations:[],cameras:[],scenes:[],asset:{},userData:{},parser:null}}}getResourceKinds(){return i}async processResource(r){const e=this._resourceLoader.getResource(r);if(!e){a.warn('Unable to find texture for resource "'+r+'".');return}const t=this._loader;if(!t)return;const s=this._downloadedArrayBuffers.get(e);if(!!s){this._downloadedArrayBuffers.delete(e);try{const o=await t.parseAsync(s,"");this._loadedThreeModels.set(e,o)}catch(o){a.error("Can't fetch the 3D model file "+e.file+", error: "+o)}}}async loadResource(r){const e=this._resourceLoader.getResource(r);if(!e){a.warn('Unable to find texture for resource "'+r+'".');return}if(!this._loader||this._loadedThreeModels.get(e))return;const s=this._resourceLoader.getFullUrl(e.file);try{const o=await fetch(s,{credentials:this._resourceLoader.checkIfCredentialsRequired(s)?"include":"omit"});if(!o.ok)throw new Error("Network response was not ok");const n=await o.arrayBuffer();this._downloadedArrayBuffers.set(e,n)}catch(o){a.error("Can't fetch the 3D model file "+e.file+", error: "+o)}}getModel(r){return this._loadedThreeModels.getFromName(r)||this._invalidModel}dispose(){this._loadedThreeModels.clear(),this._downloadedArrayBuffers.clear(),this._loader=null,this._dracoLoader=null,this._invalidModel&&(this._invalidModel.cameras=[],this._invalidModel.animations=[],this._invalidModel.scenes=[],this._invalidModel.userData={},this._invalidModel.asset={},this._invalidModel.scene.clear())}}d.Model3DManager=l})(gdjs||(gdjs={})); +//# sourceMappingURL=Model3DManager.js.map diff --git a/ResourceCache.js b/ResourceCache.js new file mode 100644 index 0000000000000000000000000000000000000000..b4e7d89df4d5a85a218e1829d792bc54a465c091 --- /dev/null +++ b/ResourceCache.js @@ -0,0 +1,2 @@ +var gdjs;(function(a){class n{constructor(){this._nameToContent=new Map;this._fileToContent=new Map}getFromName(e){return this._nameToContent.get(e)||null}get(e){let t=this._nameToContent.get(e.name);return t||(t=this._fileToContent.get(e.file),t?(this._nameToContent.set(e.name,t),t):null)}set(e,t){this._nameToContent.set(e.name,t),this._fileToContent.set(e.file,t)}delete(e){this._nameToContent.delete(e.name),this._fileToContent.delete(e.file)}clear(){this._nameToContent.clear(),this._fileToContent.clear()}}a.ResourceCache=n})(gdjs||(gdjs={})); +//# sourceMappingURL=ResourceCache.js.map diff --git a/ResourceLoader.js b/ResourceLoader.js new file mode 100644 index 0000000000000000000000000000000000000000..473557df78e8be959dbaa420481ae09fe054216e --- /dev/null +++ b/ResourceLoader.js @@ -0,0 +1,2 @@ +var gdjs;(function(i){const c=new i.Logger("ResourceLoader"),f=(t,e,s)=>{if(t.startsWith("data:")||t.startsWith("blob:"))return t;const n=t.indexOf("?")===-1?"?":"&";return t+n+e+"="+s},_=t=>t.startsWith("https://project-resources.gdevelop.io/")||t.startsWith("https://project-resources-dev.gdevelop.io/"),g=20,R=5,d=3;class v{constructor(e){this.isFinished=!1;this.sceneName=e,this.onProgressCallbacks=new Array,this.onFinishCallbacks=new Array}registerCallback(e,s){if(this.isFinished){e();return}this.onFinishCallbacks.push(e),s&&this.onProgressCallbacks.push(s)}onProgress(e,s){for(const n of this.onProgressCallbacks)n(e,s)}onFinish(){this.isFinished=!0;for(const e of this.onFinishCallbacks)e()}}class w{constructor(e,s,n,r){this._sceneToLoadQueue=new Array;this._spineAtlasManager=null;this._spineManager=null;this.currentLoadingSceneName="";this.currentSceneLoadingProgress=0;this._isLoadingInForeground=!0;this._runtimeGame=e,this._resources=new Map,this._globalResources=n,this._sceneResources=new Map,this._sceneNamesToLoad=new Set,this._sceneNamesToMakeReady=new Set,this.setResources(s,n,r),this._imageManager=new i.ImageManager(this),this._soundManager=new i.SoundManager(this),this._fontManager=new i.FontManager(this),this._jsonManager=new i.JsonManager(this),this._bitmapFontManager=new i.BitmapFontManager(this,this._imageManager),this._model3DManager=new i.Model3DManager(this),i.SpineAtlasManager&&i.SpineManager&&(this._spineAtlasManager=new i.SpineAtlasManager(this,this._imageManager),this._spineManager=new i.SpineManager(this,this._spineAtlasManager));const a=[this._imageManager,this._soundManager,this._fontManager,this._jsonManager,this._bitmapFontManager,this._model3DManager];this._spineAtlasManager&&a.push(this._spineAtlasManager),this._spineManager&&a.push(this._spineManager),this._resourceManagersMap=new Map;for(const o of a)for(const u of o.getResourceKinds())this._resourceManagersMap.set(u,o)}getRuntimeGame(){return this._runtimeGame}setResources(e,s,n){this._globalResources=s,this._sceneResources.clear(),this._sceneNamesToLoad.clear(),this._sceneNamesToMakeReady.clear();for(const r of n)this._sceneResources.set(r.name,r.usedResources.map(a=>a.name)),this._sceneNamesToLoad.add(r.name),this._sceneNamesToMakeReady.add(r.name);this._sceneToLoadQueue.length=0;for(let r=n.length-1;r>=0;r--){const a=n[r];this._sceneToLoadQueue.push(new v(a.name))}this._resources.clear();for(const r of e)!r.file||this._resources.set(r.name,r)}async loadAllResources(e){let s=0;await h([...this._resources.values()],g,d,async n=>{await this._loadResource(n),await this._processResource(n),s++,e(s,this._resources.size)}),this._sceneNamesToLoad.clear(),this._sceneNamesToMakeReady.clear()}async loadGlobalAndFirstSceneResources(e,s){const n=this._sceneResources.get(e);if(!n){c.warn(`Can't load resource for unknown scene: "`+e+'".');return}let r=0;const a=[...this._globalResources,...n.values()];await h(a,g,d,async o=>{const u=this._resources.get(o);if(!u){c.warn('Unable to find resource "'+o+'".');return}await this._loadResource(u),await this._processResource(u),r++,s(r,a.length)}),this._setSceneAssetsLoaded(e),this._setSceneAssetsReady(e)}async loadAllSceneInBackground(){for(;this._sceneToLoadQueue.length>0;){const e=this._sceneToLoadQueue[this._sceneToLoadQueue.length-1];e!==void 0&&(this.currentLoadingSceneName=e.sceneName,this.areSceneAssetsLoaded(e.sceneName)?this._sceneToLoadQueue.pop():(await this._doLoadSceneResources(e.sceneName,async(s,n)=>e.onProgress(s,n)),this._sceneToLoadQueue.splice(this._sceneToLoadQueue.findIndex(s=>s===e),1),e.onFinish()))}this.currentLoadingSceneName=""}async _doLoadSceneResources(e,s){const n=this._sceneResources.get(e);if(!n){c.warn(`Can't load resource for unknown scene: "`+e+'".');return}let r=0;await h([...n.values()],this._isLoadingInForeground?g:R,d,async a=>{const o=this._resources.get(a);if(!o){c.warn('Unable to find resource "'+a+'".');return}await this._loadResource(o),r++,this.currentSceneLoadingProgress=r/this._resources.size,s&&await s(r,this._resources.size)}),this._setSceneAssetsLoaded(e)}async _loadResource(e){const s=this._resourceManagersMap.get(e.kind);if(!s){c.warn('Unknown resource kind: "'+e.kind+'" for: "'+e.name+'".');return}await s.loadResource(e.name)}async loadAndProcessSceneResources(e,s){if(this.areSceneAssetsReady(e))return;await this.loadSceneResources(e,s);const n=this._sceneResources.get(e);if(!n){c.warn(`Can't load resource for unknown scene: "`+e+'".');return}let r=0;for(const a of n){const o=this._resources.get(a);if(!o){c.warn('Unable to find resource "'+a+'".');continue}await this._processResource(o),r++,s&&await s(r,n.length)}this._setSceneAssetsReady(e)}async loadSceneResources(e,s){this._isLoadingInForeground=!0;const n=this._prioritizeScene(e);return new Promise((r,a)=>{if(!n){this._isLoadingInForeground=!1,r();return}n.registerCallback(()=>{this._isLoadingInForeground=!1,r()},s)})}dispose(){for(const e of this._resourceManagersMap.values())e.dispose()}_prioritizeScene(e){const s=this._sceneToLoadQueue.findIndex(r=>r.sceneName===e);if(s<0)return null;const n=this._sceneToLoadQueue[s];return this._sceneToLoadQueue.splice(s,1),this._sceneToLoadQueue.push(n),n}async _processResource(e){const s=this._resourceManagersMap.get(e.kind);if(!s){c.warn('Unknown resource kind: "'+e.kind+'" for: "'+e.name+'".');return}await s.processResource(e.name)}getSceneLoadingProgress(e){return e===this.currentLoadingSceneName?this.currentSceneLoadingProgress:this.areSceneAssetsLoaded(e)?1:0}areSceneAssetsLoaded(e){return!this._sceneNamesToLoad.has(e)}areSceneAssetsReady(e){return!this._sceneNamesToMakeReady.has(e)}_setSceneAssetsLoaded(e){this._sceneNamesToLoad.delete(e)}_setSceneAssetsReady(e){this._sceneNamesToMakeReady.delete(e)}getResource(e){return this._resources.get(e)||null}getFullUrl(e){const{gdevelopResourceToken:s}=this._runtimeGame._options;return!s||!_(e)?e:f(e,"gd_resource_token",encodeURIComponent(s))}checkIfCredentialsRequired(e){return this._runtimeGame._options.gdevelopResourceToken?!1:!!_(e)}getSoundManager(){return this._soundManager}getImageManager(){return this._imageManager}getFontManager(){return this._fontManager}getBitmapFontManager(){return this._bitmapFontManager}getJsonManager(){return this._jsonManager}getModel3DManager(){return this._model3DManager}getSpineManager(){return this._spineManager}getSpineAtlasManager(){return this._spineAtlasManager}}i.ResourceLoader=w;const p=(t,e,s)=>{const n=[],r=[];let a=0,o=0;return new Promise((u,y)=>{const m=()=>{if(t.length===0){u({results:n,errors:r});return}for(;an.push(l)).catch(l=>r.push({item:M,error:l})).finally(()=>{a--,o===t.length&&a===0?u({results:n,errors:r}):m()})}};m()})},h=async(t,e,s,n)=>{const r=await p(t,e,n);r.errors.length!==0&&c.warn("Some assets couldn't be downloaded. Trying again now.");for(let a=1;aa==="3d"?1:a==="2d+3d"||a===""?2:0;let s;(function(t){t[t.PERSPECTIVE=0]="PERSPECTIVE",t[t.ORTHOGRAPHIC=1]="ORTHOGRAPHIC"})(s=i.RuntimeLayerCameraType||(i.RuntimeLayerCameraType={}));const l=a=>a==="orthographic"?1:0;let o;(function(t){t[t.DO_NOTHING=0]="DO_NOTHING",t[t.TOP_LEFT_ANCHORED_IF_NEVER_MOVED=1]="TOP_LEFT_ANCHORED_IF_NEVER_MOVED"})(o=i.RuntimeLayerDefaultCameraBehavior||(i.RuntimeLayerDefaultCameraBehavior={}));const c=a=>a==="top-left-anchored-if-never-moved"?1:0;class d{constructor(e,t){this._timeScale=1;this._defaultZOrder=0;this._rendererEffects={};this._name=e.name,this._renderingType=f(e.renderingType),this._cameraType=l(e.cameraType),this._defaultCameraBehavior=c(e.defaultCameraBehavior||"top-left-anchored-if-never-moved"),this._hidden=!e.visibility,this._initialCamera3DFieldOfView=e.camera3DFieldOfView||45,this._initialCamera3DNearPlaneDistance=e.camera3DNearPlaneDistance||.1,this._initialCamera3DFarPlaneDistance=e.camera3DFarPlaneDistance||2e3,this._initialEffectsData=e.effects||[],this._runtimeScene=t,this._effectsManager=t.getGame().getEffectsManager(),this._isLightingLayer=e.isLightingLayer,this._followBaseLayerCamera=e.followBaseLayerCamera,this._clearColor=[e.ambientLightColorR/255,e.ambientLightColorG/255,e.ambientLightColorB/255,1],this._renderer=new i.LayerRenderer(this,t.getRenderer(),t.getGame().getRenderer()),this.show(!this._hidden);for(let r=0;r=0&&(this._timeScale=e)}getTimeScale(){return this._timeScale}getElapsedTime(e){return(e||this._runtimeScene).getElapsedTime()*this._timeScale}followBaseLayer(){const e=this._runtimeScene.getLayer("");this.setCameraX(e.getCameraX()),this.setCameraY(e.getCameraY()),this.setCameraRotation(e.getCameraRotation()),this.setCameraZoom(e.getCameraZoom())}getClearColor(){return this._clearColor}setClearColor(e,t,r){this._clearColor[0]=e/255,this._clearColor[1]=t/255,this._clearColor[2]=r/255,this._renderer.updateClearColor()}setFollowBaseLayerCamera(e){this._followBaseLayerCamera=e}isLightingLayer(){return this._isLightingLayer}}i.RuntimeLayer=d})(gdjs||(gdjs={})); +//# sourceMappingURL=RuntimeLayer.js.map diff --git a/SpriteAnimator.js b/SpriteAnimator.js new file mode 100644 index 0000000000000000000000000000000000000000..8fc2b2e9c08b48ed02cd55ad3bd5a59bfab904c4 --- /dev/null +++ b/SpriteAnimator.js @@ -0,0 +1,2 @@ +var gdjs;(function(a){class c{constructor(t,i){this.center={x:0,y:0};this.origin={x:0,y:0};this.hasCustomHitBoxes=!1;this.customHitBoxes=[];this.image=t?t.image:"",this.texture=i.getAnimationFrameTexture(this.image),this.points=new Hashtable,this.reinitialize(t,i)}reinitialize(t,i){this.image=t.image,this.texture=i.getAnimationFrameTexture(this.image),this.points.clear();for(let n=0,o=t.points.length;n=this.customHitBoxes.length&&this.customHitBoxes.push(new a.Polygon);let s=0;for(const u=m.length;s=this.customHitBoxes[n].vertices.length&&this.customHitBoxes[n].vertices.push([0,0]),this.customHitBoxes[n].vertices[s][0]=l.x,this.customHitBoxes[n].vertices[s][1]=l.y}this.customHitBoxes[n].vertices.length=s}this.customHitBoxes.length=n}else this.customHitBoxes.length=0}getPoint(t){return t==="Centre"||t==="Center"?this.center:t==="Origin"?this.origin:this.points.containsKey(t)?this.points.get(t):this.origin}}a.SpriteAnimationFrame=c;class _{constructor(t,i){this.frames=[];this.timeBetweenFrames=t?t.timeBetweenFrames:1,this.loop=!!t.looping,this.reinitialize(t,i)}reinitialize(t,i){this.timeBetweenFrames=t?t.timeBetweenFrames:1,this.loop=!!t.looping;let e=0;for(const r=t.sprites.length;e=this._animations.length||this._currentDirection>=this._animations[this._currentAnimation].directions.length)return!1;const i=this._animations[this._currentAnimation].directions[this._currentDirection],e=this.getAnimationDuration();if(!this._animationPaused&&(i.loop||this._animationElapsedTime!==e)&&i.timeBetweenFrames){const r=this._animationElapsedTime+t*this._animationSpeedScale;return this.setAnimationElapsedTime(i.loop?a.evtTools.common.mod(r,e):a.evtTools.common.clamp(r,0,e))}return!1}setOnFrameChangeCallback(t){this._onFrameChange=t}getAnimationIndex(){return this._currentAnimation}setAnimationIndex(t){return t=t|0,t=0?(this._currentAnimation=t,this._currentFrameIndex=0,this._animationElapsedTime=0,this.invalidateFrame(),!0):!1}getAnimationName(){return this._currentAnimation>=this._animations.length?"":this._animations[this._currentAnimation].name}setAnimationName(t){if(!t)return!1;for(let i=0;i=this._animations.length||this._currentDirection>=this._animations[this._currentAnimation].directions.length)return!0;const t=this._animations[this._currentAnimation].directions[this._currentDirection];return t.loop?!1:this._currentFrameIndex===t.frames.length-1&&this._animationElapsedTime===t.frames.length*t.timeBetweenFrames}isAnimationPaused(){return this._animationPaused}pauseAnimation(){this._animationPaused=!0}resumeAnimation(){this._animationPaused=!1}getAnimationSpeedScale(){return this._animationSpeedScale}setAnimationSpeedScale(t){this._animationSpeedScale=t}setAnimationFrameIndex(t){if(this._currentAnimation>=this._animations.length||this._currentDirection>=this._animations[this._currentAnimation].directions.length)return!1;const i=this._animations[this._currentAnimation].directions[this._currentDirection];return t>=0&&t=this._animations.length)return 0;const t=this._animations[this._currentAnimation];return this._currentDirection>=t.directions.length?0:t.directions[this._currentDirection].frames.length}setDirectionOrAngle(t,i){if(this._currentAnimation>=this._animations.length)return null;const e=this._animations[this._currentAnimation];return e.hasMultipleDirections?(i=i|0,i===this._currentDirection||i>=e.directions.length||e.directions[i].frames.length===0?null:(this._currentDirection=i,this._currentFrameIndex=0,this._animationElapsedTime=0,this.invalidateFrame(),0)):t===i?null:i}getDirectionOrAngle(t){return this._currentAnimation>=this._animations.length?0:this._animations[this._currentAnimation].hasMultipleDirections?this._currentDirection:t}getAngle(t){return this._currentAnimation>=this._animations.length?0:this._animations[this._currentAnimation].hasMultipleDirections?this._currentDirection*45:t}setAngle(t,i){return this._currentAnimation>=this._animations.length?null:this._animations[this._currentAnimation].hasMultipleDirections?(i=i%360,i<0&&(i+=360),this.setDirectionOrAngle(t,Math.round(i/45)%8)):t===i?null:i}hasAnimationEndedLegacy(){if(this._currentAnimation>=this._animations.length||this._currentDirection>=this._animations[this._currentAnimation].directions.length)return!0;const t=this._animations[this._currentAnimation].directions[this._currentDirection];return t.loop?!1:this._currentFrameIndex===t.frames.length-1}}a.SpriteAnimator=g})(gdjs||(gdjs={})); +//# sourceMappingURL=SpriteAnimator.js.map diff --git a/Start button.png b/Start button.png new file mode 100644 index 0000000000000000000000000000000000000000..e864f62438fad4bf8d990381df1d34d2af74ad97 Binary files /dev/null and b/Start button.png differ diff --git a/affinetransformation.js b/affinetransformation.js new file mode 100644 index 0000000000000000000000000000000000000000..916c62031c3a42b48dc02d11a1580867057eac1f --- /dev/null +++ b/affinetransformation.js @@ -0,0 +1,2 @@ +var gdjs;(function(c){class y{constructor(){this.matrix=new Float32Array([1,0,0,1,0,0])}setToIdentity(){const o=this.matrix;o[0]=1,o[1]=0,o[2]=0,o[3]=1,o[4]=0,o[5]=0}isIdentity(){const o=this.matrix;return o[0]===1&&o[1]===0&&o[2]===0&&o[3]===1&&o[4]===0&&o[5]===0}equals(o){const t=this.matrix,a=o.matrix;return this===o||t[0]===a[0]&&t[1]===a[1]&&t[2]===a[2]&&t[3]===a[3]&&t[4]===a[4]&&t[5]===a[5]}nearlyEquals(o,t){const a=this.matrix,s=o.matrix;return this===o||c.nearlyEqual(a[0],s[0],t)&&c.nearlyEqual(a[1],s[1],t)&&c.nearlyEqual(a[2],s[2],t)&&c.nearlyEqual(a[3],s[3],t)&&c.nearlyEqual(a[4],s[4],t)&&c.nearlyEqual(a[5],s[5],t)}copyFrom(o){const t=this.matrix,a=o.matrix;return t[0]=a[0],t[1]=a[1],t[2]=a[2],t[3]=a[3],t[4]=a[4],t[5]=a[5],this}setToTranslation(o,t){const a=this.matrix;a[0]=1,a[1]=0,a[2]=0,a[3]=1,a[4]=o,a[5]=t}translate(o,t){var a=this.matrix;a[4]=a[0]*o+a[2]*t+a[4],a[5]=a[1]*o+a[3]*t+a[5]}setToScale(o,t){const a=this.matrix;a[0]=o,a[1]=0,a[2]=0,a[3]=t,a[4]=0,a[5]=0}scale(o,t){const a=this.matrix;a[0]*=o,a[1]*=o,a[2]*=t,a[3]*=t}setToRotation(o){const t=this.matrix;let a=Math.cos(o),s=Math.sin(o);(a===-1||a===1)&&(s=0),(s===-1||s===1)&&(a=0),t[0]=a,t[1]=s,t[2]=-s,t[3]=a,t[4]=0,t[5]=0}rotate(o){const t=this.matrix;let a=Math.cos(o),s=Math.sin(o);(a===-1||a===1)&&(s=0),(s===-1||s===1)&&(a=0);const i=t[0],n=t[1],m=t[2],r=t[3];t[0]=i*a+m*s,t[1]=n*a+r*s,t[2]=i*-s+m*a,t[3]=n*-s+r*a}setToRotationAround(o,t,a){const s=this.matrix;let i=Math.cos(o),n=Math.sin(o);(i===-1||i===1)&&(n=0),(n===-1||n===1)&&(i=0),s[0]=i,s[1]=n,s[2]=-n,s[3]=i,s[4]=t-t*i+a*n,s[5]=a-t*n+a*i}rotateAround(o,t,a){this.translate(t,a),this.rotate(o),this.translate(-t,-a)}setToFlipX(o){const t=this.matrix;t[0]=-1,t[1]=0,t[2]=0,t[3]=1,t[4]=2*o,t[5]=0}flipX(o){this.translate(o,0),this.scale(-1,1),this.translate(-o,0)}setToFlipY(o){const t=this.matrix;t[0]=-1,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=2*o}flipY(o){this.translate(0,o),this.scale(1,-1),this.translate(0,-o)}concatenate(o){const t=this.matrix,a=o.matrix,s=t[0],i=t[1],n=t[2],m=t[3],r=t[4],h=t[5],l=a[0],e=a[1],x=a[2],f=a[3],u=a[4],T=a[5];t[0]=l*s+e*n,t[1]=l*i+e*m,t[2]=x*s+f*n,t[3]=x*i+f*m,t[4]=u*s+T*n+r,t[5]=u*i+T*m+h}preConcatenate(o){const t=this.matrix,a=o.matrix,s=t[0],i=t[1],n=t[2],m=t[3],r=t[4],h=t[5],l=a[0],e=a[1],x=a[2],f=a[3],u=a[4],T=a[5];t[0]=s*l+i*x,t[1]=s*e+i*f,t[2]=n*l+m*x,t[3]=n*e+m*f,t[4]=r*l+h*x+u,t[5]=r*e+h*f+T}transform(o,t){const a=this.matrix,s=a[0]*o[0]+a[2]*o[1]+a[4],i=a[1]*o[0]+a[3]*o[1]+a[5];t[0]=s,t[1]=i}invert(){const o=this.matrix,t=o[0],a=o[1],s=o[2],i=o[3],n=o[4],m=o[5],r=t*i-a*s;return o[0]=i/r,o[1]=-a/r,o[2]=-s/r,o[3]=t/r,o[4]=(s*m-i*n)/r,o[5]=-(t*m-a*n)/r,this}toString(){const o=this.matrix;return`[[${o[0]} ${o[1]}] [${o[2]} ${o[3]}] [${o[4]} ${o[5]}]]`}}c.AffineTransformation=y})(gdjs||(gdjs={})); +//# sourceMappingURL=affinetransformation.js.map diff --git a/code0.js b/code0.js new file mode 100644 index 0000000000000000000000000000000000000000..306a45eb52d8de7a63472fe6b62876bcf7027a99 --- /dev/null +++ b/code0.js @@ -0,0 +1,110 @@ +gdjs.MainCode = {}; +gdjs.MainCode.localVariables = []; +gdjs.MainCode.GDVoiceRecognitionStatusTextObjects1= []; +gdjs.MainCode.GDVoiceRecognitionStatusTextObjects2= []; +gdjs.MainCode.GDInstructionObjects1= []; +gdjs.MainCode.GDInstructionObjects2= []; +gdjs.MainCode.GDStartButtonObjects1= []; +gdjs.MainCode.GDStartButtonObjects2= []; + + +gdjs.MainCode.mapOfGDgdjs_9546MainCode_9546GDStartButtonObjects1Objects = Hashtable.newFrom({"StartButton": gdjs.MainCode.GDStartButtonObjects1}); +gdjs.MainCode.eventsList0 = function(runtimeScene) { + +{ + + +let isConditionTrue_0 = false; +isConditionTrue_0 = false; +isConditionTrue_0 = gdjs.evtTools.runtimeScene.sceneJustBegins(runtimeScene); +if (isConditionTrue_0) { +gdjs.copyArray(runtimeScene.getObjects("VoiceRecognitionStatusText"), gdjs.MainCode.GDVoiceRecognitionStatusTextObjects1); +{gdjs.evtsExt__VoiceRecognition__StartListening.func(runtimeScene, "en-US (English)", (typeof eventsFunctionContext !== 'undefined' ? eventsFunctionContext : undefined)); +}{for(var i = 0, len = gdjs.MainCode.GDVoiceRecognitionStatusTextObjects1.length ;i < len;++i) { + gdjs.MainCode.GDVoiceRecognitionStatusTextObjects1[i].setString(gdjs.evtsExt__VoiceRecognition__RetrieveStatus.func(runtimeScene, (typeof eventsFunctionContext !== 'undefined' ? eventsFunctionContext : undefined))); +} +}} + +} + + +{ + +gdjs.copyArray(runtimeScene.getObjects("StartButton"), gdjs.MainCode.GDStartButtonObjects1); + +let isConditionTrue_0 = false; +isConditionTrue_0 = false; +isConditionTrue_0 = gdjs.evtTools.input.cursorOnObject(gdjs.MainCode.mapOfGDgdjs_9546MainCode_9546GDStartButtonObjects1Objects, runtimeScene, true, false); +if (isConditionTrue_0) { +isConditionTrue_0 = false; +isConditionTrue_0 = gdjs.evtTools.input.isMouseButtonReleased(runtimeScene, "Left"); +} +if (isConditionTrue_0) { +gdjs.copyArray(runtimeScene.getObjects("VoiceRecognitionStatusText"), gdjs.MainCode.GDVoiceRecognitionStatusTextObjects1); +{gdjs.evtsExt__VoiceRecognition__StartListening.func(runtimeScene, "en-US (English)", (typeof eventsFunctionContext !== 'undefined' ? eventsFunctionContext : undefined)); +}{for(var i = 0, len = gdjs.MainCode.GDVoiceRecognitionStatusTextObjects1.length ;i < len;++i) { + gdjs.MainCode.GDVoiceRecognitionStatusTextObjects1[i].setString(gdjs.evtsExt__VoiceRecognition__RetrieveStatus.func(runtimeScene, (typeof eventsFunctionContext !== 'undefined' ? eventsFunctionContext : undefined))); +} +}} + +} + + +{ + + +let isConditionTrue_0 = false; +isConditionTrue_0 = false; +isConditionTrue_0 = gdjs.evtsExt__VoiceRecognition__OnError.func(runtimeScene, (typeof eventsFunctionContext !== 'undefined' ? eventsFunctionContext : undefined)); +if (isConditionTrue_0) { +gdjs.copyArray(runtimeScene.getObjects("VoiceRecognitionStatusText"), gdjs.MainCode.GDVoiceRecognitionStatusTextObjects1); +{for(var i = 0, len = gdjs.MainCode.GDVoiceRecognitionStatusTextObjects1.length ;i < len;++i) { + gdjs.MainCode.GDVoiceRecognitionStatusTextObjects1[i].setString(gdjs.evtsExt__VoiceRecognition__RetrieveError.func(runtimeScene, (typeof eventsFunctionContext !== 'undefined' ? eventsFunctionContext : undefined))); +} +}} + +} + + +{ + + +let isConditionTrue_0 = false; +isConditionTrue_0 = false; +isConditionTrue_0 = gdjs.evtsExt__VoiceRecognition__OnSuccess.func(runtimeScene, (typeof eventsFunctionContext !== 'undefined' ? eventsFunctionContext : undefined)); +if (isConditionTrue_0) { +gdjs.copyArray(runtimeScene.getObjects("VoiceRecognitionStatusText"), gdjs.MainCode.GDVoiceRecognitionStatusTextObjects1); +{for(var i = 0, len = gdjs.MainCode.GDVoiceRecognitionStatusTextObjects1.length ;i < len;++i) { + gdjs.MainCode.GDVoiceRecognitionStatusTextObjects1[i].setString(gdjs.evtsExt__VoiceRecognition__RetrievetResultText.func(runtimeScene, (typeof eventsFunctionContext !== 'undefined' ? eventsFunctionContext : undefined))); +} +}} + +} + + +}; + +gdjs.MainCode.func = function(runtimeScene) { +runtimeScene.getOnceTriggers().startNewFrame(); + +gdjs.MainCode.GDVoiceRecognitionStatusTextObjects1.length = 0; +gdjs.MainCode.GDVoiceRecognitionStatusTextObjects2.length = 0; +gdjs.MainCode.GDInstructionObjects1.length = 0; +gdjs.MainCode.GDInstructionObjects2.length = 0; +gdjs.MainCode.GDStartButtonObjects1.length = 0; +gdjs.MainCode.GDStartButtonObjects2.length = 0; + +gdjs.MainCode.eventsList0(runtimeScene); +gdjs.MainCode.GDVoiceRecognitionStatusTextObjects1.length = 0; +gdjs.MainCode.GDVoiceRecognitionStatusTextObjects2.length = 0; +gdjs.MainCode.GDInstructionObjects1.length = 0; +gdjs.MainCode.GDInstructionObjects2.length = 0; +gdjs.MainCode.GDStartButtonObjects1.length = 0; +gdjs.MainCode.GDStartButtonObjects2.length = 0; + + +return; + +} + +gdjs['MainCode'] = gdjs.MainCode; diff --git a/data.js b/data.js new file mode 100644 index 0000000000000000000000000000000000000000..3530d5f244aa16a001b14e3b797e8caf848e2ffe --- /dev/null +++ b/data.js @@ -0,0 +1,2 @@ +gdjs.projectData = {"firstLayout":"","gdVersion":{"build":222,"major":5,"minor":5,"revision":0},"properties":{"adaptGameResolutionAtRuntime":true,"antialiasingMode":"MSAA","antialisingEnabledOnMobile":false,"folderProject":false,"orientation":"landscape","packageName":"com.planktonfun.voicerecognition","pixelsRounding":false,"projectUuid":"8be9daf9-aad4-4e13-b1c9-b1cf726df436","scaleMode":"linear","sizeOnStartupMode":"","templateSlug":"voice-recognition","version":"1.0.0","name":"Fresh Winter (Voice recognition)","description":"A demo for using voice recognition in gdevelop, useful for a developer looking to make voice based games/apps.","author":"","windowWidth":800,"windowHeight":600,"latestCompilationDirectory":"","maxFPS":60,"minFPS":20,"verticalSync":false,"platformSpecificAssets":{},"loadingScreen":{"backgroundColor":0,"backgroundFadeInDuration":0.2,"backgroundImageResourceName":"","gdevelopLogoStyle":"light","logoAndProgressFadeInDuration":0.2,"logoAndProgressLogoFadeInDelay":0.2,"minDuration":1.5,"progressBarColor":16777215,"progressBarHeight":20.0,"progressBarMaxWidth":200.0,"progressBarMinWidth":40.0,"progressBarWidthPercent":30.0,"showGDevelopSplash":true,"showProgressBar":true},"watermark":{"placement":"bottom-left","showWatermark":true},"authorIds":["J37o8O1JKTNpANl1quUtIZLXAll1"],"authorUsernames":[],"categories":[],"playableDevices":[],"extensionProperties":[],"platforms":[{"name":"GDevelop JS platform"}],"currentPlatform":"GDevelop JS platform"},"resources":{"resources":[{"file":"Start button.png","kind":"image","metadata":"","name":"Start button.png","smoothed":true,"userAdded":false,"origin":{"identifier":"https://resources.gdevelop-app.com/assets/On-Screen Controls/Sprites/Flat Dark/Start button.png","name":"gdevelop-asset-store"}}],"resourceFolders":[]},"objects":[],"objectsFolderStructure":{"folderName":"__ROOT"},"objectsGroups":[],"variables":[],"layouts":[{"b":209,"disableInputWhenNotFocused":true,"mangledName":"Main","name":"Main","r":209,"standardSortMethod":true,"stopSoundsOnStartup":true,"title":"","v":209,"uiSettings":{"grid":false,"gridType":"rectangular","gridWidth":32.0,"gridHeight":32.0,"gridOffsetX":0.0,"gridOffsetY":0.0,"gridColor":10401023.0,"gridAlpha":0.8,"snap":false,"zoomFactor":0.8399999999999999,"windowMask":false},"objectsGroups":[],"variables":[],"instances":[{"angle":0.0,"customSize":true,"height":96.0,"layer":"","name":"VoiceRecognitionStatusText","persistentUuid":"54a9cf18-3d55-4ac7-969a-5f4c8f876b98","width":324.0,"x":257.0,"y":234.0,"zOrder":3,"numberProperties":[],"stringProperties":[],"initialVariables":[]},{"angle":0.0,"customSize":false,"height":0.0,"layer":"","name":"Instruction","persistentUuid":"33c34643-ddcc-4c89-9704-76c8ec96d7df","width":0.0,"x":22.0,"y":38.0,"zOrder":4,"numberProperties":[],"stringProperties":[],"initialVariables":[]},{"angle":0.0,"customSize":false,"height":0.0,"layer":"","name":"StartButton","persistentUuid":"74224143-b28c-4a12-802b-58d28c13cf95","width":0.0,"x":343.0,"y":378.0,"zOrder":5,"numberProperties":[],"stringProperties":[],"initialVariables":[]}],"objects":[{"assetStoreId":"","bold":false,"italic":false,"name":"VoiceRecognitionStatusText","smoothed":true,"type":"TextObject::Text","underlined":false,"variables":[{"folded":true,"name":"text","type":"string","value":"hello there, please press space to start"}],"effects":[],"behaviors":[{"name":"Effect","type":"EffectCapability::EffectBehavior"},{"name":"Opacity","type":"OpacityCapability::OpacityBehavior"},{"name":"Scale","type":"ScalableCapability::ScalableBehavior"},{"name":"Text","type":"TextContainerCapability::TextContainerBehavior"}],"string":"to start listening press start","font":"","textAlignment":"","characterSize":20.0,"color":{"b":0,"g":0,"r":0},"content":{"bold":false,"isOutlineEnabled":false,"isShadowEnabled":false,"italic":false,"outlineColor":"255;255;255","outlineThickness":2.0,"shadowAngle":90.0,"shadowBlurRadius":2.0,"shadowColor":"0;0;0","shadowDistance":4.0,"shadowOpacity":127.0,"smoothed":true,"underlined":false,"text":"to start listening press start","font":"","textAlignment":"","verticalTextAlignment":"top","characterSize":20.0,"color":"0;0;0"}},{"assetStoreId":"","bold":false,"italic":false,"name":"Instruction","smoothed":true,"type":"TextObject::Text","underlined":false,"variables":[],"effects":[],"behaviors":[{"name":"Effect","type":"EffectCapability::EffectBehavior"},{"name":"Opacity","type":"OpacityCapability::OpacityBehavior"},{"name":"Scale","type":"ScalableCapability::ScalableBehavior"},{"name":"Text","type":"TextContainerCapability::TextContainerBehavior"}],"string":"Caveats: Voice recognition is only supported in https for security\nInstruction: To test this click publish -> generate link -> open the link","font":"","textAlignment":"","characterSize":20.0,"color":{"b":0,"g":0,"r":0},"content":{"bold":false,"isOutlineEnabled":false,"isShadowEnabled":false,"italic":false,"outlineColor":"255;255;255","outlineThickness":2.0,"shadowAngle":90.0,"shadowBlurRadius":2.0,"shadowColor":"0;0;0","shadowDistance":4.0,"shadowOpacity":127.0,"smoothed":true,"underlined":false,"text":"Caveats: Voice recognition is only supported in https for security\nInstruction: To test this click publish -> generate link -> open the link","font":"","textAlignment":"","verticalTextAlignment":"top","characterSize":20.0,"color":"0;0;0"}},{"adaptCollisionMaskAutomatically":false,"assetStoreId":"a5f25aefb989f5bf860c66e9cbdee237e4bcf7abb62a312d3fb46646352edb70","name":"StartButton","type":"Sprite","updateIfNotVisible":false,"variables":[],"effects":[],"behaviors":[{"name":"Animation","type":"AnimatableCapability::AnimatableBehavior"},{"name":"Effect","type":"EffectCapability::EffectBehavior"},{"name":"Flippable","type":"FlippableCapability::FlippableBehavior"},{"name":"Opacity","type":"OpacityCapability::OpacityBehavior"},{"name":"Resizable","type":"ResizableCapability::ResizableBehavior"},{"name":"Scale","type":"ScalableCapability::ScalableBehavior"}],"animations":[{"name":"","useMultipleDirections":false,"directions":[{"looping":true,"timeBetweenFrames":0.02500000037252903,"sprites":[{"hasCustomCollisionMask":false,"image":"Start button.png","points":[],"originPoint":{"name":"origine","x":0.0,"y":0.0},"centerPoint":{"automatic":true,"name":"centre","x":0.0,"y":0.0},"customCollisionMask":[]}]}]}]}],"objectsFolderStructure":{"folderName":"__ROOT"},"events":[],"layers":[{"ambientLightColorB":32,"ambientLightColorG":0,"ambientLightColorR":0,"camera3DFarPlaneDistance":10000.0,"camera3DFieldOfView":45.0,"camera3DNearPlaneDistance":0.1,"cameraType":"perspective","followBaseLayerCamera":false,"isLightingLayer":false,"isLocked":false,"name":"","renderingType":"","visibility":true,"cameras":[{"defaultSize":true,"defaultViewport":true,"height":0.0,"viewportBottom":1.0,"viewportLeft":0.0,"viewportRight":1.0,"viewportTop":0.0,"width":0.0}],"effects":[]}],"behaviorsSharedData":[],"usedResources":[{"name":"Start button.png"}]}],"externalEvents":[],"eventsFunctionsExtensions":[],"externalLayouts":[],"usedResources":[]}; +gdjs.runtimeGameOptions = {}; diff --git a/events-tools/cameratools.js b/events-tools/cameratools.js new file mode 100644 index 0000000000000000000000000000000000000000..5020de7e7cf3e803a1c4382d532efbb7a7676b3b --- /dev/null +++ b/events-tools/cameratools.js @@ -0,0 +1,2 @@ +var gdjs;(function(L){let I;(function(d){let b;(function(r){r.setCameraX=function(t,e,n,s){!t.hasLayer(n)||t.getLayer(n).setCameraX(e,s)},r.setCameraY=function(t,e,n,s){!t.hasLayer(n)||t.getLayer(n).setCameraY(e,s)},r.getCameraX=function(t,e,n){return t.hasLayer(e)?t.getLayer(e).getCameraX():0},r.getCameraY=function(t,e,n){return t.hasLayer(e)?t.getLayer(e).getCameraY():0},r.getCameraWidth=function(t,e,n){return t.hasLayer(e)?t.getLayer(e).getCameraWidth():0},r.getCameraHeight=function(t,e,n){return t.hasLayer(e)?t.getLayer(e).getCameraHeight():0},r.getCameraBorderLeft=function(t,e,n){return t.hasLayer(e)?r.getCameraX(t,e,n)-r.getCameraWidth(t,e,n)/2:0},r.getCameraBorderRight=function(t,e,n){return t.hasLayer(e)?r.getCameraX(t,e,n)+r.getCameraWidth(t,e,n)/2:0},r.getCameraBorderTop=function(t,e,n){return t.hasLayer(e)?r.getCameraY(t,e,n)-r.getCameraHeight(t,e,n)/2:0},r.getCameraBorderBottom=function(t,e,n){return t.hasLayer(e)?r.getCameraY(t,e,n)+r.getCameraHeight(t,e,n)/2:0},r.showLayer=function(t,e){if(!!t.hasLayer(e))return t.getLayer(e).show(!0)},r.hideLayer=function(t,e){if(!!t.hasLayer(e))return t.getLayer(e).show(!1)},r.layerIsVisible=function(t,e){return t.hasLayer(e)&&t.getLayer(e).isVisible()},r.setCameraRotation=function(t,e,n,s){if(!!t.hasLayer(n))return t.getLayer(n).setCameraRotation(e,s)},r.getCameraRotation=function(t,e,n){return t.hasLayer(e)?t.getLayer(e).getCameraRotation(n):0},r.getCameraZoom=function(t,e,n){return t.hasLayer(e)?t.getLayer(e).getCameraZoom(n):0},r.setCameraZoom=function(t,e,n,s){if(!!t.hasLayer(n))return t.getLayer(n).setCameraZoom(e,s)},r.centerCamera=function(t,e,n,s,o){if(!t.hasLayer(s)||e==null)return;let f=0,i=0;if(n&&!e.hasNoForces()){const u=e.getAverageForce(),a=e.getElapsedTime(t)/1e3;f=u.getX()*a,i=u.getY()*a}const g=t.getLayer(s);g.setCameraX(e.getCenterXInScene()+f,o),g.setCameraY(e.getCenterYInScene()+i,o)},r.centerCameraWithinLimits=function(t,e,n,s,o,f,i,g,u){r.centerCamera(t,e,i,g,u),r.clampCamera(t,n,s,o,f,g,u)},r.clampCamera=function(t,e,n,s,o,f,i){if(!t.hasLayer(f))return;const g=t.getLayer(f),u=g.getCameraWidth(i)/2,a=g.getCameraHeight(i)/2,m=e+u,c=s-u,h=n+a,p=o-a,E=m0?1:-1},n.cbrt=function(t){return Math.pow(t,1/3)},n.nthroot=function(t,e){return Math.pow(t,1/e)},n.mod=function(t,e){return t-e*Math.floor(t/e)},n.angleDifference=function(t,e){return o.evtTools.common.mod(o.evtTools.common.mod(t-e,360)+180,360)-180},n.angleBetweenPositions=function(t,e,r,i){return Math.atan2(i-e,r-t)*180/Math.PI},n.distanceBetweenPositions=function(t,e,r,i){return Math.sqrt((t-r)*(t-r)+(e-i)*(e-i))},n.lerp=function(t,e,r){return t+(e-t)*r},n.exponentialInterpolation=(t,e,r)=>{if(r===0)return t;if(r===1)return e;if(t<=0||e<=0)return 0;const i=Math.log(t),l=Math.log(e);return Math.exp(i+(l-i)*r)},n.trunc=function(t){return t|0},n.getXFromAngleAndDistance=function(t,e){return e*Math.cos(o.toRad(t))},n.getYFromAngleAndDistance=function(t,e){return e*Math.sin(o.toRad(t))},n.roundTo=function(t,e){return!e||!Number.isInteger(e)?Math.round(t):Math.round(t*Math.pow(10,e))/Math.pow(10,e)},n.floorTo=function(t,e){return!e||!Number.isInteger(e)?Math.floor(t):Math.floor(t*Math.pow(10,e))/Math.pow(10,e)},n.ceilTo=function(t,e){return!e||!Number.isInteger(e)?Math.ceil(t):Math.ceil(t*Math.pow(10,e))/Math.pow(10,e)},n.pi=function(){return Math.PI},n.lerpAngle=function(t,e,r){return t+o.evtTools.common.angleDifference(e,t)*r},n.resolveAsyncEventsFunction=t=>{!!t&&!!t.task&&!!t.task.resolve&&t.task.resolve()};const c=()=>{if(typeof cc!="undefined"&&cc.sys)return cc.sys.isMobile;if(typeof Cocoon!="undefined"&&Cocoon.App)return!0;if(typeof window!="undefined"&&window.cordova)return!0;if(typeof window!="undefined"){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent.substr(0,4))||/iPad|iPhone|iPod/.test(navigator.platform))return!0;if(/MacIntel/.test(navigator.platform))return!!navigator.maxTouchPoints&&navigator.maxTouchPoints>2}return!1};let a=null;n.isMobile=()=>a!==null?a:a=c()})(p=u.common||(u.common={}))})(s=o.evtTools||(o.evtTools={}))})(gdjs||(gdjs={})); +//# sourceMappingURL=commontools.js.map diff --git a/events-tools/inputtools.js b/events-tools/inputtools.js new file mode 100644 index 0000000000000000000000000000000000000000..46a371c3c746f299ca118b4bdbcab64398f161c3 --- /dev/null +++ b/events-tools/inputtools.js @@ -0,0 +1,2 @@ +var gdjs;(function(o){let i;(function(c){let d;(function(n){n.lastTouchId=0,n.lastEndedTouchId=0,n.keysNameToCode={a:65,b:66,c:67,d:68,e:69,f:70,g:71,h:72,i:73,j:74,k:75,l:76,m:77,n:78,o:79,p:80,q:81,r:82,s:83,t:84,u:85,v:86,w:87,x:88,y:89,z:90,Num0:48,Num1:49,Num2:50,Num3:51,Num4:52,Num5:53,Num6:54,Num7:55,Num8:56,Num9:57,Numpad0:96,Numpad1:97,Numpad2:98,Numpad3:99,Numpad4:100,Numpad5:101,Numpad6:102,Numpad7:103,Numpad8:104,Numpad9:105,LShift:1016,RShift:2016,LControl:1017,RControl:2017,LAlt:1018,RAlt:2018,LSystem:1091,RSystem:2091,SemiColon:186,Comma:188,Period:190,Quote:222,Slash:191,BackSlash:220,Equal:187,Dash:189,Menu:93,LBracket:219,RBracket:221,Tilde:192,Space:32,Back:8,Tab:9,Delete:46,Insert:45,Escape:27,PageUp:33,PageDown:34,End:35,Home:36,Return:13,NumpadPageUp:3033,NumpadPageDown:3034,NumpadEnd:3035,NumpadHome:3036,NumpadReturn:3013,Add:107,Subtract:109,Multiply:106,Divide:111,NumpadAdd:3107,NumpadSubtract:3109,NumpadMultiply:3106,NumpadDivide:3111,Left:37,Up:38,Right:39,Down:40,NumpadLeft:3037,NumpadUp:3038,NumpadRight:3039,NumpadDown:3040,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,Pause:19};const u={};for(const e in n.keysNameToCode)n.keysNameToCode.hasOwnProperty(e)&&(u[n.keysNameToCode[e]]=e);n.mouseButtonsNameToCode={Left:o.InputManager.MOUSE_LEFT_BUTTON,Right:o.InputManager.MOUSE_RIGHT_BUTTON,Middle:o.InputManager.MOUSE_MIDDLE_BUTTON,Back:o.InputManager.MOUSE_BACK_BUTTON,Forward:o.InputManager.MOUSE_FORWARD_BUTTON},n.isKeyPressed=function(e,t){return o.evtTools.input.keysNameToCode.hasOwnProperty(t)?e.getGame().getInputManager().isKeyPressed(o.evtTools.input.keysNameToCode[t]):!1},n.wasKeyReleased=function(e,t){return o.evtTools.input.keysNameToCode.hasOwnProperty(t)?e.getGame().getInputManager().wasKeyReleased(o.evtTools.input.keysNameToCode[t]):!1},n.lastPressedKey=function(e){const t=e.getGame().getInputManager().getLastPressedKey();return u.hasOwnProperty(t)?u[t]:""},n.anyKeyPressed=function(e){return e.getGame().getInputManager().anyKeyPressed()},n.anyKeyReleased=function(e){return e.getGame().getInputManager().anyKeyReleased()},n.isMouseButtonPressed=function(e,t){return o.evtTools.input.mouseButtonsNameToCode.hasOwnProperty(t)?e.getGame().getInputManager().isMouseButtonPressed(o.evtTools.input.mouseButtonsNameToCode[t]):!1},n.isMouseButtonReleased=function(e,t){return o.evtTools.input.mouseButtonsNameToCode.hasOwnProperty(t)?e.getGame().getInputManager().isMouseButtonReleased(o.evtTools.input.mouseButtonsNameToCode[t]):!1},n.hideCursor=function(e){e.getScene().getRenderer().hideCursor()},n.showCursor=function(e){e.getScene().getRenderer().showCursor()},n.getMouseWheelDelta=function(e){return e.getGame().getInputManager().getMouseWheelDelta()},n.isScrollingUp=function(e){return e.getGame().getInputManager().isScrollingUp()},n.isScrollingDown=function(e){return e.getGame().getInputManager().isScrollingDown()},n.getMouseX=function(e,t,r){return n.getCursorX(e,t,r)},n.getMouseY=function(e,t,r){return n.getCursorY(e,t,r)},n.getCursorX=function(e,t,r){const a=o.staticArray(o.evtTools.input.getCursorX);return e.getLayer(t).convertCoords(e.getGame().getInputManager().getCursorX(),e.getGame().getInputManager().getCursorY(),0,a)[0]},n.getCursorY=function(e,t,r){const a=o.staticArray(o.evtTools.input.getCursorY);return e.getLayer(t).convertCoords(e.getGame().getInputManager().getCursorX(),e.getGame().getInputManager().getCursorY(),0,a)[1]},n.getMouseOnlyCursorX=function(e,t,r){const a=o.staticArray(o.evtTools.input.getMouseOnlyCursorX);return e.getLayer(t).convertCoords(e.getGame().getInputManager().getMouseX(),e.getGame().getInputManager().getMouseY(),0,a)[0]},n.getMouseOnlyCursorY=function(e,t,r){const a=o.staticArray(o.evtTools.input.getMouseOnlyCursorY);return e.getLayer(t).convertCoords(e.getGame().getInputManager().getMouseX(),e.getGame().getInputManager().getMouseY(),0,a)[1]},n.isMouseInsideCanvas=function(e){return e.getGame().getInputManager().isMouseInsideCanvas()};const I=function(e,t){return e.cursorOnObject(t)};n.cursorOnObject=function(e,t,r,a){return o.evtTools.object.pickObjectsIf(I,e,a,t)},n.getTouchX=function(e,t,r,a){const g=o.staticArray(o.evtTools.input.getTouchX);return e.getLayer(r).convertCoords(e.getGame().getInputManager().getTouchX(t),e.getGame().getInputManager().getTouchY(t),0,g)[0]},n.getTouchY=(e,t,r,a)=>{const g=o.staticArray(o.evtTools.input.getTouchY);return e.getLayer(r).convertCoords(e.getGame().getInputManager().getTouchX(t),e.getGame().getInputManager().getTouchY(t),0,g)[1]},n.hasAnyTouchStarted=e=>{const t=e.getGame().getInputManager().getStartedTouchIdentifiers();return t.length>1||t.length>0&&t[0]!==o.InputManager.MOUSE_TOUCH_ID},n.getStartedTouchCount=e=>{const t=e.getGame().getInputManager().getStartedTouchIdentifiers();return t.length+(t.includes(o.InputManager.MOUSE_TOUCH_ID)?-1:0)},n.getStartedTouchIdentifier=(e,t)=>{const r=e.getGame().getInputManager().getStartedTouchIdentifiers(),a=r.indexOf(o.InputManager.MOUSE_TOUCH_ID);return a<0?r[t]:r[te.getGame().getInputManager().getStartedTouchIdentifiers().length>0,n.getStartedTouchOrMouseCount=e=>e.getGame().getInputManager().getStartedTouchIdentifiers().length,n.getStartedTouchOrMouseIdentifier=(e,t)=>e.getGame().getInputManager().getStartedTouchIdentifiers()[t]||0,n.hasTouchEnded=(e,t)=>e.getGame().getInputManager().hasTouchEnded(t),n.getLastTouchId=function(){return o.evtTools.input.lastTouchId||0},n.getLastEndedTouchId=function(){return o.evtTools.input.lastEndedTouchId||0},n.popStartedTouch=function(e){const t=e.getGame().getInputManager().popStartedTouch();return t!==void 0?(o.evtTools.input.lastTouchId=t,!0):!1},n.popEndedTouch=function(e){const t=e.getGame().getInputManager().popEndedTouch();return t!==void 0?(o.evtTools.input.lastEndedTouchId=t,!0):!1},n.touchSimulateMouse=function(e,t){e.getGame().getInputManager().touchSimulateMouse(t)}})(d=c.input||(c.input={}))})(i=o.evtTools||(o.evtTools={}))})(gdjs||(gdjs={})); +//# sourceMappingURL=inputtools.js.map diff --git a/events-tools/networktools.js b/events-tools/networktools.js new file mode 100644 index 0000000000000000000000000000000000000000..73d071b90d7f890809a73fac7bc2ba7285ff164e --- /dev/null +++ b/events-tools/networktools.js @@ -0,0 +1,2 @@ +var gdjs;(function(u){let p;(function(g){let d;(function(r){r.sendAsyncRequest=function(n,s,i,o,c,a){const e=t=>{t instanceof ProgressEvent&&t.currentTarget&&t.currentTarget instanceof XMLHttpRequest&&t.currentTarget.status===0?a.setString("REQUEST_NOT_SENT"):a.setString(""+t)};try{const t=new XMLHttpRequest;t.onerror=e,t.ontimeout=e,t.onabort=e,t.onreadystatechange=()=>{t.readyState===4&&(t.status>=400&&e(""+t.status),c.setString(t.responseText))},t.open(i,n),t.setRequestHeader("Content-Type",o===""?"application/x-www-form-urlencoded":o),t.send(s)}catch(t){e(t)}},r.sendAwaitableAsyncRequest=(n,s,i,o,c,a)=>new u.PromiseTask(fetch(n,{body:i!=="GET"?s:void 0,method:i,headers:{"Content-Type":o||"application/x-www-form-urlencoded"}}).then(async e=>{const t=await e.text();e.status>=400&&a.setString(""+e.status),c.setString(t)},e=>{a.setString(""+e)})),r.sendDeprecatedSynchronousRequest=function(n,s,i,o,c,a){try{let e;if(typeof XMLHttpRequest!="undefined")e=new XMLHttpRequest;else{const t=["MSXML2.XmlHttp.5.0","MSXML2.XmlHttp.4.0","MSXML2.XmlHttp.3.0","MSXML2.XmlHttp.2.0","Microsoft.XmlHttp"];for(let l=0,b=t.length;l=s&&(n=s-1);let i=0,f=null;for(let r in t.items)if(t.items.hasOwnProperty(r)){let u=t.items[r];if(n-i=j&&(j=p.farSqDist,a=k,c=p.farX,l=p.farY))}}return a?(o.evtTools.object.pickOnly(e,a),f.setNumber(c),r.setNumber(l),!0):!1},g.doCreateObjectOnScene=function(e,t,s,n,i,f){const r=e.createObject(t),u=e.getLayer(f);return r!==null&&(r.setPosition(n,i),r.setLayer(f),r.setZOrder(u.getDefaultZOrder()),s.containsKey(t)&&s.get(t).push(r)),r},g.createObjectOnScene=function(e,t,s,n,i){return o.evtTools.object.doCreateObjectOnScene(e,t.firstKey(),t,s,n,i)},g.createObjectFromGroupOnScene=function(e,t,s,n,i,f){o.evtTools.object.doCreateObjectOnScene(e,s,t,n,i,f)},g.getPickedInstancesCount=e=>{let t=0;const s=o.staticArray(o.evtTools.object.getPickedInstancesCount);e.values(s);for(let n=0,i=s.length;n{let s=0;const n=o.staticArray(o.evtTools.object.getSceneInstancesCount);t.keys(n);const i=new Set(n);for(const f of i)s+=e.getInstancesCountOnScene(f);return s},g.pickedObjectsCount=g.getPickedInstancesCount})(w=O.object||(O.object={}))})(y=o.evtTools||(o.evtTools={}));class C{constructor(){this.objectsLists=new Map;this.localVariablesContainers=[];this.callbacks=new Map;this.parent=null}static from(O){const h=new C;return h.parent=O,h}getOrCreateList(O){return this.objectsLists.has(O)||this.objectsLists.set(O,[]),this.objectsLists.get(O)}getObjects(O){return!this.objectsLists.has(O)&&this.parent?this.parent.getObjects(O):this.objectsLists.get(O)||[]}addObject(O,h){const m=this.getOrCreateList(O);if(m.includes(h))return;m.push(h);const v=()=>this.removeObject(O,h);this.callbacks.set(h,v),h.registerDestroyCallback(v)}removeObject(O,h){const m=this.getOrCreateList(O),v=m.indexOf(h);v!==-1&&(m.splice(v,1),h.unregisterDestroyCallback(this.callbacks.get(h)),this.callbacks.delete(h))}restoreLocalVariablesContainers(O){o.copyArray(this.localVariablesContainers,O)}backupLocalVariablesContainers(O){o.copyArray(O,this.localVariablesContainers)}}o.LongLivedObjectsList=C})(gdjs||(gdjs={})); +//# sourceMappingURL=objecttools.js.map diff --git a/events-tools/runtimescenetools.js b/events-tools/runtimescenetools.js new file mode 100644 index 0000000000000000000000000000000000000000..8f7deb9ea09e0c95c6c54965e174bdba0a7a8f2c --- /dev/null +++ b/events-tools/runtimescenetools.js @@ -0,0 +1,2 @@ +var gdjs;(function(r){let c;(function(i){let u;(function(s){s.sceneJustBegins=function(e){return e.getScene().getTimeManager().isFirstFrame()},s.sceneJustResumed=function(e){return e.getScene().sceneJustResumed()},s.getSceneName=function(e){return e.getScene().getName()},s.setBackgroundColor=function(e,t){const n=t.split(";");n.length<3||e.getScene().setBackgroundColor(parseInt(n[0]),parseInt(n[1]),parseInt(n[2]))},s.getElapsedTimeInSeconds=function(e){return e.getScene().getTimeManager().getElapsedTime()/1e3},s.setTimeScale=function(e,t){return e.getScene().getTimeManager().setTimeScale(t)},s.getTimeScale=function(e){return e.getScene().getTimeManager().getTimeScale()},s.timerElapsedTime=function(e,t,n){const a=e.getScene().getTimeManager();return a.hasTimer(n)?a.getTimer(n).getTime()/1e3>=t:(a.addTimer(n),!1)},s.timerPaused=function(e,t){const n=e.getScene().getTimeManager();return n.hasTimer(t)?n.getTimer(t).isPaused():!1},s.resetTimer=function(e,t){const n=e.getScene().getTimeManager();n.hasTimer(t)?n.getTimer(t).reset():n.addTimer(t)},s.pauseTimer=function(e,t){const n=e.getScene().getTimeManager();n.hasTimer(t)||n.addTimer(t),n.getTimer(t).setPaused(!0)},s.unpauseTimer=function(e,t){const n=e.getScene().getTimeManager();return n.hasTimer(t)||n.addTimer(t),n.getTimer(t).setPaused(!1)},s.removeTimer=function(e,t){e.getScene().getTimeManager().removeTimer(t)};class m extends r.AsyncTask{constructor(t){super();this.timeElapsedOnScene=0;this.duration=t}update(t){return this.timeElapsedOnScene+=t.getScene().getTimeManager().getElapsedTime(),this.timeElapsedOnScene>=this.duration}}s.WaitTask=m,s.wait=e=>new m(e*1e3),s.getTimerElapsedTimeInSeconds=function(e,t){const n=e.getScene().getTimeManager();return n.hasTimer(t)?n.getTimer(t).getTime()/1e3:0},s.getTimerElapsedTimeInSecondsOrNaN=function(e,t){const n=e.getScene().getTimeManager();return n.hasTimer(t)?n.getTimer(t).getTime()/1e3:Number.NaN},s.getTimeFromStartInSeconds=function(e){return e.getScene().getTimeManager().getTimeFromStart()/1e3},s.getTime=function(e,t){if(t==="timestamp")return Date.now();const n=new Date;if(t==="hour")return n.getHours();if(t==="min")return n.getMinutes();if(t==="sec")return n.getSeconds();if(t==="mday")return n.getDate();if(t==="mon")return n.getMonth();if(t==="year")return n.getFullYear()-1900;if(t==="wday")return n.getDay();if(t==="yday"){const a=new Date(n.getFullYear(),0,0),o=n.getTime()-a.getTime(),g=1e3*60*60*24;return Math.floor(o/g)}return 0},s.replaceScene=function(e,t,n){!e.getGame().getSceneAndExtensionsData(t)||e.getScene().requestChange(n?r.SceneChangeRequest.CLEAR_SCENES:r.SceneChangeRequest.REPLACE_SCENE,t)},s.pushScene=function(e,t){!e.getGame().getSceneAndExtensionsData(t)||e.getScene().requestChange(r.SceneChangeRequest.PUSH_SCENE,t)},s.popScene=function(e){e.getScene().requestChange(r.SceneChangeRequest.POP_SCENE)},s.stopGame=function(e){e.getScene().requestChange(r.SceneChangeRequest.STOP_GAME)},s.createObjectsFromExternalLayout=function(e,t,n,a,o){const g=e.getGame().getExternalLayoutData(t);g!==null&&e.getScene().createObjectsFrom(g.instances,n,a,o||0,!1)},s.hasGameJustResumed=e=>e.getGame().hasJustResumed(),s.doesSceneExist=(e,t)=>e.getGame().hasScene(t),s.prioritizeLoadingOfScene=(e,t)=>{e.getGame().prioritizeLoadingOfScene(t)},s.getSceneLoadingProgress=(e,t)=>e.getGame().getSceneLoadingProgress(t),s.areSceneAssetsLoaded=(e,t)=>e.getGame().areSceneAssetsLoaded(t)})(u=i.runtimeScene||(i.runtimeScene={}))})(c=r.evtTools||(r.evtTools={}))})(gdjs||(gdjs={})); +//# sourceMappingURL=runtimescenetools.js.map diff --git a/events-tools/soundtools.js b/events-tools/soundtools.js new file mode 100644 index 0000000000000000000000000000000000000000..ec587a1590ad107564155a052aabc3c2e876fd14 --- /dev/null +++ b/events-tools/soundtools.js @@ -0,0 +1,2 @@ +var gdjs;(function(u){let s;(function(i){let r;(function(o){o.getGlobalVolume=function(n){return n.getScene().getSoundManager().getGlobalVolume()},o.setGlobalVolume=function(n,t){n.getScene().getSoundManager().setGlobalVolume(t)},o.unloadAllAudio=function(n){n.getScene().getSoundManager().unloadAll()},o.playSound=function(n,t,e,g,a){n.getScene().getSoundManager().playSound(t,e,g,a)},o.playSoundOnChannel=function(n,t,e,g,a,c){n.getScene().getSoundManager().playSoundOnChannel(t,e,g,a,c)},o.stopSoundOnChannel=function(n,t){const e=n.getScene().getSoundManager().getSoundOnChannel(t);e&&e.stop()},o.pauseSoundOnChannel=function(n,t){const e=n.getScene().getSoundManager().getSoundOnChannel(t);e&&e.pause()},o.continueSoundOnChannel=function(n,t){const e=n.getScene().getSoundManager().getSoundOnChannel(t);e&&(e.playing()||e.play())},o.isSoundOnChannelPlaying=function(n,t){const e=n.getScene().getSoundManager().getSoundOnChannel(t);return e?e.playing():!1},o.isSoundOnChannelPaused=function(n,t){const e=n.getScene().getSoundManager().getSoundOnChannel(t);return e?e.paused():!1},o.isSoundOnChannelStopped=function(n,t){const e=n.getScene().getSoundManager().getSoundOnChannel(t);return e?e.stopped():!0},o.getSoundOnChannelVolume=function(n,t){const e=n.getScene().getSoundManager().getSoundOnChannel(t);return e?e.getVolume()*100:100},o.setSoundOnChannelVolume=function(n,t,e){const g=n.getScene().getSoundManager().getSoundOnChannel(t);g&&g.setVolume(e/100)},o.getSoundOnChannelPlayingOffset=function(n,t){const e=n.getScene().getSoundManager().getSoundOnChannel(t);return e?e.getSeek():0},o.setSoundOnChannelPlayingOffset=function(n,t,e){const g=n.getScene().getSoundManager().getSoundOnChannel(t);g&&g.setSeek(e)},o.getSoundOnChannelPitch=function(n,t){const e=n.getScene().getSoundManager().getSoundOnChannel(t);return e?e.getRate():1},o.setSoundOnChannelPitch=function(n,t,e){const g=n.getScene().getSoundManager().getSoundOnChannel(t);g&&g.setRate(e)},o.preloadSound=(n,t)=>n.getScene().getSoundManager().loadAudio(t,!1),o.unloadSound=(n,t)=>n.getScene().getSoundManager().unloadAudio(t,!1),o.playMusic=function(n,t,e,g,a){n.getScene().getSoundManager().playMusic(t,e,g,a)},o.playMusicOnChannel=function(n,t,e,g,a,c){n.getScene().getSoundManager().playMusicOnChannel(t,e,g,a,c)},o.stopMusicOnChannel=function(n,t){const e=n.getScene().getSoundManager().getMusicOnChannel(t);e&&e.stop()},o.pauseMusicOnChannel=function(n,t){const e=n.getScene().getSoundManager().getMusicOnChannel(t);e&&e.pause()},o.continueMusicOnChannel=function(n,t){const e=n.getScene().getSoundManager().getMusicOnChannel(t);e&&(e.playing()||e.play())},o.isMusicOnChannelPlaying=function(n,t){const e=n.getScene().getSoundManager().getMusicOnChannel(t);return e?e.playing():!1},o.isMusicOnChannelPaused=function(n,t){const e=n.getScene().getSoundManager().getMusicOnChannel(t);return e?e.paused():!1},o.isMusicOnChannelStopped=function(n,t){const e=n.getScene().getSoundManager().getMusicOnChannel(t);return e?e.stopped():!0},o.getMusicOnChannelVolume=function(n,t){const e=n.getScene().getSoundManager().getMusicOnChannel(t);return e?e.getVolume()*100:100},o.setMusicOnChannelVolume=function(n,t,e){const g=n.getScene().getSoundManager().getMusicOnChannel(t);g&&g.setVolume(e/100)},o.getMusicOnChannelPlayingOffset=function(n,t){const e=n.getScene().getSoundManager().getMusicOnChannel(t);return e?e.getSeek():0},o.setMusicOnChannelPlayingOffset=function(n,t,e){const g=n.getScene().getSoundManager().getMusicOnChannel(t);g&&g.setSeek(e)},o.getMusicOnChannelPitch=function(n,t){const e=n.getScene().getSoundManager().getMusicOnChannel(t);return e?e.getRate():1},o.setMusicOnChannelPitch=function(n,t,e){const g=n.getScene().getSoundManager().getMusicOnChannel(t);g&&g.setRate(e)},o.preloadMusic=(n,t)=>n.getScene().getSoundManager().loadAudio(t,!0),o.unloadMusic=(n,t)=>n.getScene().getSoundManager().unloadAudio(t,!0),o.fadeSoundVolume=(n,t,e,g)=>{const a=n.getScene().getSoundManager().getSoundOnChannel(t);a&&a.fade(a.getVolume(),e/100,g*1e3)},o.fadeMusicVolume=(n,t,e,g)=>{const a=n.getScene().getSoundManager().getMusicOnChannel(t);a&&a.fade(a.getVolume(),e/100,g*1e3)}})(r=i.sound||(i.sound={}))})(s=u.evtTools||(u.evtTools={}))})(gdjs||(gdjs={})); +//# sourceMappingURL=soundtools.js.map diff --git a/events-tools/storagetools.js b/events-tools/storagetools.js new file mode 100644 index 0000000000000000000000000000000000000000..2a41f6d93b1f087c700b3d715cd52eebfe18c2ba --- /dev/null +++ b/events-tools/storagetools.js @@ -0,0 +1,2 @@ +var gdjs;(function(S){const f=new S.Logger("Storage");let d;(function(p){let h;(function(a){let c=null;try{typeof cc!="undefined"?c=cc.sys.localStorage:typeof window!="undefined"&&(c=window.localStorage)}catch(t){f.error("Unable to get access to the localStorage: "+t)}c||f.error("Storage actions won't work as no localStorage was found.");const u=new Hashtable;a.loadJSONFileFromStorage=t=>{if(u.containsKey(t))return;let i=null;try{c&&(i=c.getItem("GDJS_"+t))}catch(l){f.error('Unable to load data from localStorage for "'+t+'": '+l)}let o={};try{i&&(o=JSON.parse(i))}catch(l){f.error('Unable to load data from "'+t+'" - data is not valid JSON: '+l)}u.put(t,o)},a.unloadJSONFile=t=>{if(!u.containsKey(t))return;const i=u.get(t),o=JSON.stringify(i);try{c&&c.setItem("GDJS_"+t,o)}catch(l){f.error('Unable to save data to localStorage for "'+t+'": '+l)}u.remove(t)};const g=(t,i)=>{let o=!1;u.containsKey(t)||(o=!0,a.loadJSONFileFromStorage(t));const l=i(u.get(t));return o&&a.unloadJSONFile(t),l};a.clearJSONFile=t=>g(t,i=>{for(const o in i)i.hasOwnProperty(o)&&delete i[o];return!0}),a.elementExistsInJSONFile=(t,i)=>g(t,o=>{const l=i.split("/");let n=o;for(let e=0;eg(t,o=>{const l=i.split("/");let n=o;for(let e=0;eg(t,l=>{const n=i.split("/");let e=l;for(let r=0;rg(t,l=>{const n=i.split("/");let e=l;for(let r=0;rg(t,n=>{const e=i.split("/");let r=n;for(let s=0;sg(t,n=>{const e=i.split("/");let r=n;for(let s=0;s=0?t.substr(n,r):""},e.strAt=function(t,n){return n=0?t.substr(n,1):""},e.strRepeat=function(t,n){let r="";for(let o=0;oo.length));)i=o.indexOf(n,u);return o},e.strRFindFrom=s.evtTools.string.strFindLastFrom})(f=c.string||(c.string={}))})(p=s.evtTools||(s.evtTools={}))})(gdjs||(gdjs={})); +//# sourceMappingURL=stringtools.js.map diff --git a/events-tools/variabletools.js b/events-tools/variabletools.js new file mode 100644 index 0000000000000000000000000000000000000000..4d87d6f30937e0eae3963b0b59f007590b24f8f7 --- /dev/null +++ b/events-tools/variabletools.js @@ -0,0 +1,2 @@ +var gdjs;(function(a){let l;(function(o){let i;(function(r){r.getVariableNumber=function(e){return e.getAsNumber()},r.getVariableString=function(e){return e.getAsString()},r.getVariableBoolean=function(e,t){return e.getAsBoolean()===t},r.setVariableBoolean=function(e,t){e.setBoolean(t)},r.toggleVariableBoolean=function(e){e.setBoolean(!e.getAsBoolean())},r.sceneVariableExists=function(e,t){return e.getScene().getVariables().has(t)},r.globalVariableExists=function(e,t){return e.getGame().getVariables().has(t)},r.variableChildExists=function(e,t){return e.hasChild(t)},r.variableRemoveChild=function(e,t){e.removeChild(t)},r.variableClearChildren=function(e){e.clearChildren()},r.variablePushCopy=function(e,t){e.pushVariableCopy(t)},r.valuePush=function(e,t){e.pushValue(t)},r.variableRemoveAt=function(e,t){e.removeAtIndex(t)},r.getVariableChildCount=function(e){return e.getChildrenCount()},r.getFirstVariableNumber=function(e){return e.getChildrenCount()===0?0:e.getAllChildrenArray()[0].getAsNumber()},r.getFirstVariableString=function(e){return e.getChildrenCount()===0?"":e.getAllChildrenArray()[0].getAsString()},r.getLastVariableNumber=function(e){const t=e.getAllChildrenArray();return t.length===0?0:t[t.length-1].getAsNumber()},r.getLastVariableString=function(e){const t=e.getAllChildrenArray();return t.length===0?"":t[t.length-1].getAsString()}})(i=o.variable||(o.variable={}));let s;(function(n){n.getVariableNumber=a.evtTools.variable.getVariableNumber,n.getVariableString=a.evtTools.variable.getVariableString,n.getVariableBoolean=a.evtTools.variable.getVariableBoolean,n.setVariableBoolean=a.evtTools.variable.setVariableBoolean,n.toggleVariableBoolean=a.evtTools.variable.toggleVariableBoolean,n.sceneVariableExists=a.evtTools.variable.sceneVariableExists,n.globalVariableExists=a.evtTools.variable.globalVariableExists,n.variableChildExists=a.evtTools.variable.variableChildExists,n.variableRemoveChild=a.evtTools.variable.variableRemoveChild,n.variableClearChildren=a.evtTools.variable.variableClearChildren,n.variablePushCopy=a.evtTools.variable.variablePushCopy,n.valuePush=a.evtTools.variable.valuePush,n.variableRemoveAt=a.evtTools.variable.variableRemoveAt,n.getVariableChildCount=a.evtTools.variable.getVariableChildCount})(s=o.common||(o.common={}))})(l=a.evtTools||(a.evtTools={}))})(gdjs||(gdjs={})); +//# sourceMappingURL=variabletools.js.map diff --git a/events-tools/windowtools.js b/events-tools/windowtools.js new file mode 100644 index 0000000000000000000000000000000000000000..080febda32163735e9cb9e0683ee2bbc03796ab1 --- /dev/null +++ b/events-tools/windowtools.js @@ -0,0 +1,2 @@ +var gdjs;(function(r){let s;(function(u){let m;(function(t){t.setMargins=function(e,n,o,i,g){e.getGame().getRenderer().setMargins(n,o,i,g)},t.setFullScreen=function(e,n,o){e.getGame().getRenderer().keepAspectRatio(o),e.getGame().getRenderer().setFullScreen(n)},t.isFullScreen=function(e){return e.getGame().getRenderer().isFullScreen()},t.setWindowSize=function(e,n,o,i){e.getGame().getRenderer().setWindowSize(n,o),i&&e.getGame().setGameResolutionSize(n,o)},t.centerWindow=function(e){e.getGame().getRenderer().centerWindow()},t.setGameResolutionSize=function(e,n,o){e.getGame().setGameResolutionSize(n,o)},t.setGameResolutionResizeMode=function(e,n){e.getGame().setGameResolutionResizeMode(n)},t.setAdaptGameResolutionAtRuntime=function(e,n){e.getGame().setAdaptGameResolutionAtRuntime(n)},t.setWindowTitle=function(e,n){e.getGame().getRenderer().setWindowTitle(n)},t.getWindowTitle=function(e){return e.getGame().getRenderer().getWindowTitle()},t.getWindowInnerWidth=function(){return r.RuntimeGameRenderer&&r.RuntimeGameRenderer.getWindowInnerWidth?r.RuntimeGameRenderer.getWindowInnerWidth():typeof t!="undefined"?t.innerWidth:800},t.getWindowInnerHeight=function(){return r.RuntimeGameRenderer&&r.RuntimeGameRenderer.getWindowInnerHeight?r.RuntimeGameRenderer.getWindowInnerHeight():typeof t!="undefined"?t.innerHeight:800},t.getGameResolutionWidth=function(e){return e.getGame().getGameResolutionWidth()},t.getGameResolutionHeight=function(e){return e.getGame().getGameResolutionHeight()},t.openURL=function(e,n){return n.getGame().getRenderer().openURL(e)}})(m=u.window||(u.window={}))})(s=r.evtTools||(r.evtTools={}))})(gdjs||(gdjs={})); +//# sourceMappingURL=windowtools.js.map diff --git a/fontfaceobserver-font-manager/fontfaceobserver-font-manager.js b/fontfaceobserver-font-manager/fontfaceobserver-font-manager.js new file mode 100644 index 0000000000000000000000000000000000000000..b9bef0857ef672205d4e69b02e0681cda995b0ac --- /dev/null +++ b/fontfaceobserver-font-manager/fontfaceobserver-font-manager.js @@ -0,0 +1,2 @@ +var gdjs;(function(i){const s=new i.Logger("Font manager"),d=["font"];class c{constructor(r){this._loadedFontFamily=new i.ResourceCache;this._loadedFontFamilySet=new Set;this._resourceLoader=r}getResourceKinds(){return d}getFontFamily(r){return this._loadedFontFamily.getFromName(r)||"Arial"}getFontFile(r){const e=this._resourceLoader.getResource(r);return e?e.file||"":r}_getFontFamilyFromFilename(r){let e="gdjs_font_"+r.file.toLowerCase().replace(/[^\w]/gi,"-");const o=e;let n=2;for(;this._loadedFontFamilySet.has(e);)e=e+"-"+n,n++;return o}_loadFont(r,e){const o={},n="url("+encodeURI(e)+")";if(typeof FontFace!="undefined")return fetch(this._resourceLoader.getFullUrl(e),{credentials:this._resourceLoader.checkIfCredentialsRequired(e)?"include":"same-origin"}).then(t=>{if(!t.ok){const a="Unable to fetch "+e+" to be loaded as a font. HTTP status is: "+t.status+".";throw s.error(a),new Error(a)}return t.arrayBuffer()}).then(t=>{const a=new FontFace(r,t,o);document.fonts.add(a)});{const t=document.createElement("style");return t.appendChild(document.createTextNode("@font-face { font-family: '"+r+"'; src: "+n+"; }")),document.head.appendChild(t),new FontFaceObserver(r,o).load()}}async processResource(r){}async loadResource(r){const e=this._resourceLoader.getResource(r);if(!e){s.warn('Unable to find font for resource "'+r+'".');return}if(this._loadedFontFamily.get(e))return;const o=e.file;if(!o)return;const n=this._getFontFamilyFromFilename(e);this._loadedFontFamily.set(e,n),this._loadedFontFamilySet.add(n);try{await this._loadFont(n,o)}catch(t){s.error('Error loading font resource "'+e.name+'" (file: '+o+"): "+(t.message||"Unknown error"))}}dispose(){this._loadedFontFamily.clear(),this._loadedFontFamilySet.clear()}}i.FontFaceObserverFontManager=c,i.FontManager=c})(gdjs||(gdjs={})); +//# sourceMappingURL=fontfaceobserver-font-manager.js.map diff --git a/fontfaceobserver-font-manager/fontfaceobserver.js b/fontfaceobserver-font-manager/fontfaceobserver.js new file mode 100644 index 0000000000000000000000000000000000000000..3ff4b31f89ff9c3854135a09035b65654de419cb --- /dev/null +++ b/fontfaceobserver-font-manager/fontfaceobserver.js @@ -0,0 +1,16 @@ +(function() { +var module; //Define an undefined module variable to avoid fontfaceobserver thinking it's used in an environment using require. + +/* Font Face Observer v2.0.13 - © Bram Stein. License: BSD-3-Clause */(function(){'use strict';var f,g=[];function l(a){g.push(a);1==g.length&&f()}function m(){for(;g.length;)g[0](),g.shift()}f=function(){setTimeout(m)};function n(a){this.a=p;this.b=void 0;this.f=[];var b=this;try{a(function(a){q(b,a)},function(a){r(b,a)})}catch(c){r(b,c)}}var p=2;function t(a){return new n(function(b,c){c(a)})}function u(a){return new n(function(b){b(a)})}function q(a,b){if(a.a==p){if(b==a)throw new TypeError;var c=!1;try{var d=b&&b.then;if(null!=b&&"object"==typeof b&&"function"==typeof d){d.call(b,function(b){c||q(a,b);c=!0},function(b){c||r(a,b);c=!0});return}}catch(e){c||r(a,e);return}a.a=0;a.b=b;v(a)}} +function r(a,b){if(a.a==p){if(b==a)throw new TypeError;a.a=1;a.b=b;v(a)}}function v(a){l(function(){if(a.a!=p)for(;a.f.length;){var b=a.f.shift(),c=b[0],d=b[1],e=b[2],b=b[3];try{0==a.a?"function"==typeof c?e(c.call(void 0,a.b)):e(a.b):1==a.a&&("function"==typeof d?e(d.call(void 0,a.b)):b(a.b))}catch(h){b(h)}}})}n.prototype.g=function(a){return this.c(void 0,a)};n.prototype.c=function(a,b){var c=this;return new n(function(d,e){c.f.push([a,b,d,e]);v(c)})}; +function w(a){return new n(function(b,c){function d(c){return function(d){h[c]=d;e+=1;e==a.length&&b(h)}}var e=0,h=[];0==a.length&&b(h);for(var k=0;kparseInt(a[1],10)}else C=!1;return C}function J(){null===F&&(F=!!document.fonts);return F} +function K(){if(null===E){var a=document.createElement("div");try{a.style.font="condensed 100px sans-serif"}catch(b){}E=""!==a.style.font}return E}function L(a,b){return[a.style,a.weight,K()?a.stretch:"","100px",b].join(" ")} +A.prototype.load=function(a,b){var c=this,k=a||"BESbswy",q=0,D=b||3E3,H=(new Date).getTime();return new Promise(function(a,b){if(J()&&!G()){var M=new Promise(function(a,b){function e(){(new Date).getTime()-H>=D?b():document.fonts.load(L(c,'"'+c.family+'"'),k).then(function(c){1<=c.length?a():setTimeout(e,25)},function(){b()})}e()}),N=new Promise(function(a,c){q=setTimeout(c,D)});Promise.race([N,M]).then(function(){clearTimeout(q);a(c)},function(){b(c)})}else m(function(){function u(){var b;if(b=-1!= +f&&-1!=g||-1!=f&&-1!=h||-1!=g&&-1!=h)(b=f!=g&&f!=h&&g!=h)||(null===B&&(b=/AppleWebKit\/([0-9]+)(?:\.([0-9]+))/.exec(window.navigator.userAgent),B=!!b&&(536>parseInt(b[1],10)||536===parseInt(b[1],10)&&11>=parseInt(b[2],10))),b=B&&(f==v&&g==v&&h==v||f==w&&g==w&&h==w||f==x&&g==x&&h==x)),b=!b;b&&(d.parentNode&&d.parentNode.removeChild(d),clearTimeout(q),a(c))}function I(){if((new Date).getTime()-H>=D)d.parentNode&&d.parentNode.removeChild(d),b(c);else{var a=document.hidden;if(!0===a||void 0===a)f=e.a.offsetWidth, +g=n.a.offsetWidth,h=p.a.offsetWidth,u();q=setTimeout(I,50)}}var e=new r(k),n=new r(k),p=new r(k),f=-1,g=-1,h=-1,v=-1,w=-1,x=-1,d=document.createElement("div");d.dir="ltr";t(e,L(c,"sans-serif"));t(n,L(c,"serif"));t(p,L(c,"monospace"));d.appendChild(e.a);d.appendChild(n.a);d.appendChild(p.a);document.body.appendChild(d);v=e.a.offsetWidth;w=n.a.offsetWidth;x=p.a.offsetWidth;I();z(e,function(a){f=a;u()});t(e,L(c,'"'+c.family+'",sans-serif'));z(n,function(a){g=a;u()});t(n,L(c,'"'+c.family+'",serif')); +z(p,function(a){h=a;u()});t(p,L(c,'"'+c.family+'",monospace'))})})};"object"===typeof module?module.exports=A:(window.FontFaceObserver=A,window.FontFaceObserver.prototype.load=A.prototype.load);}()); +})() \ No newline at end of file diff --git a/force.js b/force.js new file mode 100644 index 0000000000000000000000000000000000000000..b2002e647935512b13e662cfe4e4ec1d870e374b --- /dev/null +++ b/force.js @@ -0,0 +1,2 @@ +var gdjs;(function(e){class s{constructor(t,i,h){this._dirty=!1;this._x=t||0,this._y=i||0,this._angle=Math.atan2(i,t)*180/Math.PI,this._length=Math.sqrt(t*t+i*i),this._multiplier=h}getX(){return this._x}getY(){return this._y}setX(t){this._x=t,this._dirty=!0}setY(t){this._y=t,this._dirty=!0}clear(){this._x=0,this._y=0,this._length=0,this._dirty=!1}addForce(t){this._x+=t._x,this._y+=t._y,this._dirty=!0}add(t,i){this._x+=t,this._y+=i,this._dirty=!0}setAngle(t){this._dirty&&(this._length=Math.sqrt(this._x*this._x+this._y*this._y),this._dirty=!1),this._angle=t;const i=t/180*Math.PI;this._x=Math.cos(i)*this._length,this._y=Math.sin(i)*this._length}setLength(t){this._dirty&&(this._angle=Math.atan2(this._y,this._x)*180/Math.PI,this._dirty=!1),this._length=t;const i=this._angle/180*Math.PI;this._x=Math.cos(i)*this._length,this._y=Math.sin(i)*this._length}getAngle(){return this._dirty&&(this._angle=Math.atan2(this._y,this._x)*180/Math.PI,this._length=Math.sqrt(this._x*this._x+this._y*this._y),this._dirty=!1),this._angle}getLength(){return this._dirty&&(this._angle=Math.atan2(this._y,this._x)*180/Math.PI,this._length=Math.sqrt(this._x*this._x+this._y*this._y),this._dirty=!1),this._length}getMultiplier(){return this._multiplier}setMultiplier(t){this._multiplier=t}getNetworkSyncData(){return{x:this._x,y:this._y,a:this._angle,l:this._length,m:this._multiplier}}updateFromNetworkSyncData(t){this._x=t.x,this._y=t.y,this._angle=t.a,this._length=t.l,this._multiplier=t.m}}e.Force=s})(gdjs||(gdjs={})); +//# sourceMappingURL=force.js.map diff --git a/gd.js b/gd.js new file mode 100644 index 0000000000000000000000000000000000000000..552369e4abc83e5c75bd625d287721f21f6997f2 --- /dev/null +++ b/gd.js @@ -0,0 +1,2 @@ +var gdjs;(function(t){const i=new t.Logger("Engine runtime"),l=/^(#{0,1}[A-Fa-f0-9]{6})$/,s=/^(#{0,1}[A-Fa-f0-9]{3})$/,b=/^(\d{1,3};\d{1,3};\d{1,3})/;let f;(function(n){const e=!0})(f=t.evtTools||(t.evtTools={})),t.objectsTypes=new Hashtable,t.behaviorsTypes=new Hashtable,t.callbacksFirstRuntimeSceneLoaded=[],t.callbacksRuntimeSceneLoaded=[],t.callbacksRuntimeScenePreEvents=[],t.callbacksRuntimeScenePostEvents=[],t.callbacksRuntimeScenePaused=[],t.callbacksRuntimeSceneResumed=[],t.callbacksRuntimeSceneUnloading=[],t.callbacksRuntimeSceneUnloaded=[],t.callbacksObjectDeletedFromScene=[],t.gdevelopLogo="",t.rgbToHex=function(e,n,r){return""+((1<<24)+(e<<16)+(n<<8)+r).toString(16).slice(1)},t.hexToRGBColor=function(e){const n=parseInt(e.replace("#",""),16);return Number.isFinite(n)?[n>>16&255,n>>8&255,n&255]:[0,0,0]},t.shorthandHexToRGBColor=function(e){const n=parseInt(e.replace("#",""),16);return Number.isFinite(n)?[17*(n>>8&15),17*(n>>4&15),17*(n&15)]:[0,0,0]},t.rgbOrHexToRGBColor=function(e){const n=t.extractRGBString(e);if(n){const a=n.split(";");if(a.length===3)return[Math.min(255,parseInt(a[0],10)),Math.min(255,parseInt(a[1],10)),Math.min(255,parseInt(a[2],10))]}const r=t.extractHexString(e);if(r)return t.hexToRGBColor(r);const o=t.extractShorthandHexString(e);return o?t.shorthandHexToRGBColor(o):[0,0,0]},t.rgbOrHexStringToNumber=e=>{const n=t.rgbOrHexToRGBColor(e);return t.rgbToHexNumber(n[0],n[1],n[2])},t.rgbToHexNumber=function(e,n,r){return(e<<16)+(n<<8)+r},t.hexNumberToRGB=e=>({r:e>>16&255,g:e>>8&255,b:e&255,a:255}),t.hexNumberToRGBArray=e=>[e>>16&255,e>>8&255,e&255],t.extractHexString=e=>{const n=e.match(l);return n?n[0]:null},t.extractShorthandHexString=e=>{const n=e.match(s);return n?n[0]:null},t.extractRGBString=e=>{const n=e.match(b);return n?n[0]:null},t.random=function(e){return e<=0?0:Math.floor(Math.random()*(e+1))},t.randomInRange=function(e,n){return e+t.random(n-e)},t.randomFloat=function(e){return e<=0?0:Math.random()*e},t.randomFloatInRange=function(e,n){return e+t.randomFloat(n-e)},t.randomWithStep=function(e,n,r){return r<=0?e+t.random(n-e):e+t.random(Math.floor((n-e)/r))*r},t.toRad=function(e){return e/180*Math.PI},t.toDegrees=function(e){return e*180/Math.PI},t.registerObject=function(e,n){t.objectsTypes.put(e,n)},t.registerBehavior=function(e,n){t.behaviorsTypes.put(e,n)},t.registerFirstRuntimeSceneLoadedCallback=function(e){t.callbacksFirstRuntimeSceneLoaded.push(e)},t.registerRuntimeSceneLoadedCallback=function(e){t.callbacksRuntimeSceneLoaded.push(e)},t.registerRuntimeScenePreEventsCallback=function(e){t.callbacksRuntimeScenePreEvents.push(e)},t.registerRuntimeScenePostEventsCallback=function(e){t.callbacksRuntimeScenePostEvents.push(e)},t.registerRuntimeScenePausedCallback=function(e){t.callbacksRuntimeScenePaused.push(e)},t.registerRuntimeSceneResumedCallback=function(e){t.callbacksRuntimeSceneResumed.push(e)},t.registerRuntimeSceneUnloadingCallback=function(e){t.callbacksRuntimeSceneUnloading.push(e)},t.registerRuntimeSceneUnloadedCallback=function(e){t.callbacksRuntimeSceneUnloaded.push(e)},t.registerObjectDeletedFromSceneCallback=function(e){t.callbacksObjectDeletedFromScene.push(e)},t._unregisterCallback=function(e){const n=r=>{for(let o=0;oa?(a^Math.random()*16>>a/4).toString(16):(""+1e7+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,o);return o()}if(!t.makeUuid.hex){t.makeUuid.hex=[];for(var e=0;e<256;e++)t.makeUuid.hex[e]=(e<16?"0":"")+e.toString(16)}const n=t.makeUuid.hex;var r=crypto.getRandomValues(new Uint8Array(16));return r[6]=r[6]&15|64,r[8]=r[8]&63|128,n[r[0]]+n[r[1]]+n[r[2]]+n[r[3]]+"-"+n[r[4]]+n[r[5]]+"-"+n[r[6]]+n[r[7]]+"-"+n[r[8]]+n[r[9]]+"-"+n[r[10]]+n[r[11]]+n[r[12]]+n[r[13]]+n[r[14]]+n[r[15]]},t.nearlyEqual=(e,n,r)=>{const o=Math.abs(e),a=Math.abs(n),c=Math.abs(e-n);return e===n?!0:e==0||n==0||o+a{u.push(e)},t.getAllAsynchronouslyLoadingLibraryPromise=()=>Promise.all(u)})(gdjs||(gdjs={})),console.warn=console.warn||console.log,console.error=console.error||console.log; +//# sourceMappingURL=gd.js.map diff --git a/gdjs-evtsext__voicerecognition__onerror-func.js b/gdjs-evtsext__voicerecognition__onerror-func.js new file mode 100644 index 0000000000000000000000000000000000000000..30ae99f675cf1c186b4c13b62c824d7ef206e66f --- /dev/null +++ b/gdjs-evtsext__voicerecognition__onerror-func.js @@ -0,0 +1,97 @@ + +if (typeof gdjs.evtsExt__VoiceRecognition__OnError !== "undefined") { + gdjs.evtsExt__VoiceRecognition__OnError.registeredGdjsCallbacks.forEach(callback => + gdjs._unregisterCallback(callback) + ); +} + +gdjs.evtsExt__VoiceRecognition__OnError = {}; + + +gdjs.evtsExt__VoiceRecognition__OnError.userFunc0x857568 = function GDJSInlineCode(runtimeScene, eventsFunctionContext) { +"use strict"; +eventsFunctionContext.returnValue = gdjs._extensionVoiceRecognition.errorStatus; +}; +gdjs.evtsExt__VoiceRecognition__OnError.eventsList0 = function(runtimeScene, eventsFunctionContext) { + +{ + + +let isConditionTrue_0 = false; +{ +} + +} + + +{ + + +gdjs.evtsExt__VoiceRecognition__OnError.userFunc0x857568(runtimeScene, typeof eventsFunctionContext !== 'undefined' ? eventsFunctionContext : undefined); + +} + + +}; + +gdjs.evtsExt__VoiceRecognition__OnError.func = function(runtimeScene, parentEventsFunctionContext) { +var eventsFunctionContext = { + _objectsMap: { +}, + _objectArraysMap: { +}, + _behaviorNamesMap: { +}, + globalVariablesForExtension: runtimeScene.getGame().getVariablesForExtension("VoiceRecognition"), + sceneVariablesForExtension: runtimeScene.getScene().getVariablesForExtension("VoiceRecognition"), + localVariables: [], + getObjects: function(objectName) { + return eventsFunctionContext._objectArraysMap[objectName] || []; + }, + getObjectsLists: function(objectName) { + return eventsFunctionContext._objectsMap[objectName] || null; + }, + getBehaviorName: function(behaviorName) { + return eventsFunctionContext._behaviorNamesMap[behaviorName] || behaviorName; + }, + createObject: function(objectName) { + const objectsList = eventsFunctionContext._objectsMap[objectName]; + if (objectsList) { + const object = parentEventsFunctionContext ? + parentEventsFunctionContext.createObject(objectsList.firstKey()) : + runtimeScene.createObject(objectsList.firstKey()); + if (object) { + objectsList.get(objectsList.firstKey()).push(object); + eventsFunctionContext._objectArraysMap[objectName].push(object); + } + return object; } + return null; + }, + getInstancesCountOnScene: function(objectName) { + const objectsList = eventsFunctionContext._objectsMap[objectName]; + let count = 0; + if (objectsList) { + for(const objectName in objectsList.items) + count += parentEventsFunctionContext ? +parentEventsFunctionContext.getInstancesCountOnScene(objectName) : + runtimeScene.getInstancesCountOnScene(objectName); + } + return count; + }, + getLayer: function(layerName) { + return runtimeScene.getLayer(layerName); + }, + getArgument: function(argName) { + return ""; + }, + getOnceTriggers: function() { return runtimeScene.getOnceTriggers(); } +}; + + +gdjs.evtsExt__VoiceRecognition__OnError.eventsList0(runtimeScene, eventsFunctionContext); + + +return !!eventsFunctionContext.returnValue; +} + +gdjs.evtsExt__VoiceRecognition__OnError.registeredGdjsCallbacks = []; \ No newline at end of file diff --git a/gdjs-evtsext__voicerecognition__onfirstsceneloaded-func.js b/gdjs-evtsext__voicerecognition__onfirstsceneloaded-func.js new file mode 100644 index 0000000000000000000000000000000000000000..e3bd3c8b123696802025ae460f98c58fe8bc1396 --- /dev/null +++ b/gdjs-evtsext__voicerecognition__onfirstsceneloaded-func.js @@ -0,0 +1,183 @@ + +if (typeof gdjs.evtsExt__VoiceRecognition__onFirstSceneLoaded !== "undefined") { + gdjs.evtsExt__VoiceRecognition__onFirstSceneLoaded.registeredGdjsCallbacks.forEach(callback => + gdjs._unregisterCallback(callback) + ); +} + +gdjs.evtsExt__VoiceRecognition__onFirstSceneLoaded = {}; + + +gdjs.evtsExt__VoiceRecognition__onFirstSceneLoaded.userFunc0x83f3a8 = function GDJSInlineCode(runtimeScene, eventsFunctionContext) { +"use strict"; +function VoiceRecognition() { + this.errorStatus = false; + this.successStatus = false; + + this.setStatus = function (status) { + this.status = status; + } + + this.setError = function (error) { + this.error = error; + } + + this.setResultText = function (result) { + this.result = result; + } + + this.getResultText = function () { + return this.result; + } + + this.getStatus = function () { + return this.status; + } + + this.getError = function () { + return this.error; + } + + this.setLanguage = function (lang) { + this.recognition.lang = lang; + } + + let parent = this; + + var SpeechRecognition = SpeechRecognition || webkitSpeechRecognition + var SpeechGrammarList = SpeechGrammarList || window.webkitSpeechGrammarList + var SpeechRecognitionEvent = SpeechRecognitionEvent || webkitSpeechRecognitionEvent + + this.recognition = new SpeechRecognition(); + + this.recognition.continuous = false; + this.recognition.interimResults = false; + this.recognition.maxAlternatives = 1; + + // This runs when the speech recognition service starts + this.recognition.onstart = function() { + parent.setStatus("listening, please speak..."); + }; + + this.recognition.onspeechend = function() { + parent.recognition.stop(); + } + + this.recognition.onerror = function(event) { + parent.errorStatus = true; + parent.setError('Error occurred in recognition: ' + event.error); + } + + // This runs when the speech recognition service returns result + this.recognition.onresult = function(event) { + var transcript = event.results[0][0].transcript; + var confidence = event.results[0][0].confidence; + + parent.successStatus = true; + parent.confidence = confidence; + parent.setResultText(transcript); + }; + + // start recognition + this.startListening = function() { + parent.recognition.start(); + + parent.errorStatus = false; + parent.successStatus = false; + parent.setStatus("listening, please speak..."); + } +} + +if(gdjs._extensionVoiceRecognition == undefined) { + gdjs._extensionVoiceRecognition = new VoiceRecognition(); +} + + +}; +gdjs.evtsExt__VoiceRecognition__onFirstSceneLoaded.eventsList0 = function(runtimeScene, eventsFunctionContext) { + +{ + + +let isConditionTrue_0 = false; +{ +} + +} + + +{ + + +gdjs.evtsExt__VoiceRecognition__onFirstSceneLoaded.userFunc0x83f3a8(runtimeScene, typeof eventsFunctionContext !== 'undefined' ? eventsFunctionContext : undefined); + +} + + +}; + +gdjs.evtsExt__VoiceRecognition__onFirstSceneLoaded.func = function(runtimeScene, parentEventsFunctionContext) { +var eventsFunctionContext = { + _objectsMap: { +}, + _objectArraysMap: { +}, + _behaviorNamesMap: { +}, + globalVariablesForExtension: runtimeScene.getGame().getVariablesForExtension("VoiceRecognition"), + sceneVariablesForExtension: runtimeScene.getScene().getVariablesForExtension("VoiceRecognition"), + localVariables: [], + getObjects: function(objectName) { + return eventsFunctionContext._objectArraysMap[objectName] || []; + }, + getObjectsLists: function(objectName) { + return eventsFunctionContext._objectsMap[objectName] || null; + }, + getBehaviorName: function(behaviorName) { + return eventsFunctionContext._behaviorNamesMap[behaviorName] || behaviorName; + }, + createObject: function(objectName) { + const objectsList = eventsFunctionContext._objectsMap[objectName]; + if (objectsList) { + const object = parentEventsFunctionContext ? + parentEventsFunctionContext.createObject(objectsList.firstKey()) : + runtimeScene.createObject(objectsList.firstKey()); + if (object) { + objectsList.get(objectsList.firstKey()).push(object); + eventsFunctionContext._objectArraysMap[objectName].push(object); + } + return object; } + return null; + }, + getInstancesCountOnScene: function(objectName) { + const objectsList = eventsFunctionContext._objectsMap[objectName]; + let count = 0; + if (objectsList) { + for(const objectName in objectsList.items) + count += parentEventsFunctionContext ? +parentEventsFunctionContext.getInstancesCountOnScene(objectName) : + runtimeScene.getInstancesCountOnScene(objectName); + } + return count; + }, + getLayer: function(layerName) { + return runtimeScene.getLayer(layerName); + }, + getArgument: function(argName) { + return ""; + }, + getOnceTriggers: function() { return runtimeScene.getOnceTriggers(); } +}; + + +gdjs.evtsExt__VoiceRecognition__onFirstSceneLoaded.eventsList0(runtimeScene, eventsFunctionContext); + + +return; +} + +gdjs.evtsExt__VoiceRecognition__onFirstSceneLoaded.registeredGdjsCallbacks = []; +gdjs.evtsExt__VoiceRecognition__onFirstSceneLoaded.registeredGdjsCallbacks.push((runtimeScene) => { + gdjs.evtsExt__VoiceRecognition__onFirstSceneLoaded.func(runtimeScene, runtimeScene); +}) +gdjs.registerFirstRuntimeSceneLoadedCallback(gdjs.evtsExt__VoiceRecognition__onFirstSceneLoaded.registeredGdjsCallbacks[gdjs.evtsExt__VoiceRecognition__onFirstSceneLoaded.registeredGdjsCallbacks.length - 1]); diff --git a/gdjs-evtsext__voicerecognition__onsuccess-func.js b/gdjs-evtsext__voicerecognition__onsuccess-func.js new file mode 100644 index 0000000000000000000000000000000000000000..83f0dadae7bfc1c91f18d5ba55a8b93480c07040 --- /dev/null +++ b/gdjs-evtsext__voicerecognition__onsuccess-func.js @@ -0,0 +1,97 @@ + +if (typeof gdjs.evtsExt__VoiceRecognition__OnSuccess !== "undefined") { + gdjs.evtsExt__VoiceRecognition__OnSuccess.registeredGdjsCallbacks.forEach(callback => + gdjs._unregisterCallback(callback) + ); +} + +gdjs.evtsExt__VoiceRecognition__OnSuccess = {}; + + +gdjs.evtsExt__VoiceRecognition__OnSuccess.userFunc0x857568 = function GDJSInlineCode(runtimeScene, eventsFunctionContext) { +"use strict"; +eventsFunctionContext.returnValue = gdjs._extensionVoiceRecognition.successStatus; +}; +gdjs.evtsExt__VoiceRecognition__OnSuccess.eventsList0 = function(runtimeScene, eventsFunctionContext) { + +{ + + +let isConditionTrue_0 = false; +{ +} + +} + + +{ + + +gdjs.evtsExt__VoiceRecognition__OnSuccess.userFunc0x857568(runtimeScene, typeof eventsFunctionContext !== 'undefined' ? eventsFunctionContext : undefined); + +} + + +}; + +gdjs.evtsExt__VoiceRecognition__OnSuccess.func = function(runtimeScene, parentEventsFunctionContext) { +var eventsFunctionContext = { + _objectsMap: { +}, + _objectArraysMap: { +}, + _behaviorNamesMap: { +}, + globalVariablesForExtension: runtimeScene.getGame().getVariablesForExtension("VoiceRecognition"), + sceneVariablesForExtension: runtimeScene.getScene().getVariablesForExtension("VoiceRecognition"), + localVariables: [], + getObjects: function(objectName) { + return eventsFunctionContext._objectArraysMap[objectName] || []; + }, + getObjectsLists: function(objectName) { + return eventsFunctionContext._objectsMap[objectName] || null; + }, + getBehaviorName: function(behaviorName) { + return eventsFunctionContext._behaviorNamesMap[behaviorName] || behaviorName; + }, + createObject: function(objectName) { + const objectsList = eventsFunctionContext._objectsMap[objectName]; + if (objectsList) { + const object = parentEventsFunctionContext ? + parentEventsFunctionContext.createObject(objectsList.firstKey()) : + runtimeScene.createObject(objectsList.firstKey()); + if (object) { + objectsList.get(objectsList.firstKey()).push(object); + eventsFunctionContext._objectArraysMap[objectName].push(object); + } + return object; } + return null; + }, + getInstancesCountOnScene: function(objectName) { + const objectsList = eventsFunctionContext._objectsMap[objectName]; + let count = 0; + if (objectsList) { + for(const objectName in objectsList.items) + count += parentEventsFunctionContext ? +parentEventsFunctionContext.getInstancesCountOnScene(objectName) : + runtimeScene.getInstancesCountOnScene(objectName); + } + return count; + }, + getLayer: function(layerName) { + return runtimeScene.getLayer(layerName); + }, + getArgument: function(argName) { + return ""; + }, + getOnceTriggers: function() { return runtimeScene.getOnceTriggers(); } +}; + + +gdjs.evtsExt__VoiceRecognition__OnSuccess.eventsList0(runtimeScene, eventsFunctionContext); + + +return !!eventsFunctionContext.returnValue; +} + +gdjs.evtsExt__VoiceRecognition__OnSuccess.registeredGdjsCallbacks = []; \ No newline at end of file diff --git a/gdjs-evtsext__voicerecognition__retrieveerror-func.js b/gdjs-evtsext__voicerecognition__retrieveerror-func.js new file mode 100644 index 0000000000000000000000000000000000000000..1bef03ff8720c2e0d8933195be43730d67016154 --- /dev/null +++ b/gdjs-evtsext__voicerecognition__retrieveerror-func.js @@ -0,0 +1,107 @@ + +if (typeof gdjs.evtsExt__VoiceRecognition__RetrieveError !== "undefined") { + gdjs.evtsExt__VoiceRecognition__RetrieveError.registeredGdjsCallbacks.forEach(callback => + gdjs._unregisterCallback(callback) + ); +} + +gdjs.evtsExt__VoiceRecognition__RetrieveError = {}; + + +gdjs.evtsExt__VoiceRecognition__RetrieveError.userFunc0x85fd38 = function GDJSInlineCode(runtimeScene, eventsFunctionContext) { +"use strict"; +eventsFunctionContext.returnValue = gdjs._extensionVoiceRecognition.getError(); +}; +gdjs.evtsExt__VoiceRecognition__RetrieveError.eventsList0 = function(runtimeScene, eventsFunctionContext) { + +{ + + +let isConditionTrue_0 = false; +{ +} + +} + + +{ + + +let isConditionTrue_0 = false; +{ +} + +} + + +{ + + +gdjs.evtsExt__VoiceRecognition__RetrieveError.userFunc0x85fd38(runtimeScene, typeof eventsFunctionContext !== 'undefined' ? eventsFunctionContext : undefined); + +} + + +}; + +gdjs.evtsExt__VoiceRecognition__RetrieveError.func = function(runtimeScene, parentEventsFunctionContext) { +var eventsFunctionContext = { + _objectsMap: { +}, + _objectArraysMap: { +}, + _behaviorNamesMap: { +}, + globalVariablesForExtension: runtimeScene.getGame().getVariablesForExtension("VoiceRecognition"), + sceneVariablesForExtension: runtimeScene.getScene().getVariablesForExtension("VoiceRecognition"), + localVariables: [], + getObjects: function(objectName) { + return eventsFunctionContext._objectArraysMap[objectName] || []; + }, + getObjectsLists: function(objectName) { + return eventsFunctionContext._objectsMap[objectName] || null; + }, + getBehaviorName: function(behaviorName) { + return eventsFunctionContext._behaviorNamesMap[behaviorName] || behaviorName; + }, + createObject: function(objectName) { + const objectsList = eventsFunctionContext._objectsMap[objectName]; + if (objectsList) { + const object = parentEventsFunctionContext ? + parentEventsFunctionContext.createObject(objectsList.firstKey()) : + runtimeScene.createObject(objectsList.firstKey()); + if (object) { + objectsList.get(objectsList.firstKey()).push(object); + eventsFunctionContext._objectArraysMap[objectName].push(object); + } + return object; } + return null; + }, + getInstancesCountOnScene: function(objectName) { + const objectsList = eventsFunctionContext._objectsMap[objectName]; + let count = 0; + if (objectsList) { + for(const objectName in objectsList.items) + count += parentEventsFunctionContext ? +parentEventsFunctionContext.getInstancesCountOnScene(objectName) : + runtimeScene.getInstancesCountOnScene(objectName); + } + return count; + }, + getLayer: function(layerName) { + return runtimeScene.getLayer(layerName); + }, + getArgument: function(argName) { + return ""; + }, + getOnceTriggers: function() { return runtimeScene.getOnceTriggers(); } +}; + + +gdjs.evtsExt__VoiceRecognition__RetrieveError.eventsList0(runtimeScene, eventsFunctionContext); + + +return "" + eventsFunctionContext.returnValue; +} + +gdjs.evtsExt__VoiceRecognition__RetrieveError.registeredGdjsCallbacks = []; \ No newline at end of file diff --git a/gdjs-evtsext__voicerecognition__retrievestatus-func.js b/gdjs-evtsext__voicerecognition__retrievestatus-func.js new file mode 100644 index 0000000000000000000000000000000000000000..82c366dec53a0aaf4f44aaec5691ca6cbc0497ac --- /dev/null +++ b/gdjs-evtsext__voicerecognition__retrievestatus-func.js @@ -0,0 +1,107 @@ + +if (typeof gdjs.evtsExt__VoiceRecognition__RetrieveStatus !== "undefined") { + gdjs.evtsExt__VoiceRecognition__RetrieveStatus.registeredGdjsCallbacks.forEach(callback => + gdjs._unregisterCallback(callback) + ); +} + +gdjs.evtsExt__VoiceRecognition__RetrieveStatus = {}; + + +gdjs.evtsExt__VoiceRecognition__RetrieveStatus.userFunc0x73f000 = function GDJSInlineCode(runtimeScene, eventsFunctionContext) { +"use strict"; +eventsFunctionContext.returnValue = gdjs._extensionVoiceRecognition.getStatus(); +}; +gdjs.evtsExt__VoiceRecognition__RetrieveStatus.eventsList0 = function(runtimeScene, eventsFunctionContext) { + +{ + + +let isConditionTrue_0 = false; +{ +} + +} + + +{ + + +let isConditionTrue_0 = false; +{ +} + +} + + +{ + + +gdjs.evtsExt__VoiceRecognition__RetrieveStatus.userFunc0x73f000(runtimeScene, typeof eventsFunctionContext !== 'undefined' ? eventsFunctionContext : undefined); + +} + + +}; + +gdjs.evtsExt__VoiceRecognition__RetrieveStatus.func = function(runtimeScene, parentEventsFunctionContext) { +var eventsFunctionContext = { + _objectsMap: { +}, + _objectArraysMap: { +}, + _behaviorNamesMap: { +}, + globalVariablesForExtension: runtimeScene.getGame().getVariablesForExtension("VoiceRecognition"), + sceneVariablesForExtension: runtimeScene.getScene().getVariablesForExtension("VoiceRecognition"), + localVariables: [], + getObjects: function(objectName) { + return eventsFunctionContext._objectArraysMap[objectName] || []; + }, + getObjectsLists: function(objectName) { + return eventsFunctionContext._objectsMap[objectName] || null; + }, + getBehaviorName: function(behaviorName) { + return eventsFunctionContext._behaviorNamesMap[behaviorName] || behaviorName; + }, + createObject: function(objectName) { + const objectsList = eventsFunctionContext._objectsMap[objectName]; + if (objectsList) { + const object = parentEventsFunctionContext ? + parentEventsFunctionContext.createObject(objectsList.firstKey()) : + runtimeScene.createObject(objectsList.firstKey()); + if (object) { + objectsList.get(objectsList.firstKey()).push(object); + eventsFunctionContext._objectArraysMap[objectName].push(object); + } + return object; } + return null; + }, + getInstancesCountOnScene: function(objectName) { + const objectsList = eventsFunctionContext._objectsMap[objectName]; + let count = 0; + if (objectsList) { + for(const objectName in objectsList.items) + count += parentEventsFunctionContext ? +parentEventsFunctionContext.getInstancesCountOnScene(objectName) : + runtimeScene.getInstancesCountOnScene(objectName); + } + return count; + }, + getLayer: function(layerName) { + return runtimeScene.getLayer(layerName); + }, + getArgument: function(argName) { + return ""; + }, + getOnceTriggers: function() { return runtimeScene.getOnceTriggers(); } +}; + + +gdjs.evtsExt__VoiceRecognition__RetrieveStatus.eventsList0(runtimeScene, eventsFunctionContext); + + +return "" + eventsFunctionContext.returnValue; +} + +gdjs.evtsExt__VoiceRecognition__RetrieveStatus.registeredGdjsCallbacks = []; \ No newline at end of file diff --git a/gdjs-evtsext__voicerecognition__retrievetresulttext-func.js b/gdjs-evtsext__voicerecognition__retrievetresulttext-func.js new file mode 100644 index 0000000000000000000000000000000000000000..92d30ddadd4f710a6d568ab5fe6a6d4b80a97eb5 --- /dev/null +++ b/gdjs-evtsext__voicerecognition__retrievetresulttext-func.js @@ -0,0 +1,107 @@ + +if (typeof gdjs.evtsExt__VoiceRecognition__RetrievetResultText !== "undefined") { + gdjs.evtsExt__VoiceRecognition__RetrievetResultText.registeredGdjsCallbacks.forEach(callback => + gdjs._unregisterCallback(callback) + ); +} + +gdjs.evtsExt__VoiceRecognition__RetrievetResultText = {}; + + +gdjs.evtsExt__VoiceRecognition__RetrievetResultText.userFunc0x73c578 = function GDJSInlineCode(runtimeScene, eventsFunctionContext) { +"use strict"; +eventsFunctionContext.returnValue = gdjs._extensionVoiceRecognition.getResultText(); +}; +gdjs.evtsExt__VoiceRecognition__RetrievetResultText.eventsList0 = function(runtimeScene, eventsFunctionContext) { + +{ + + +let isConditionTrue_0 = false; +{ +} + +} + + +{ + + +let isConditionTrue_0 = false; +{ +} + +} + + +{ + + +gdjs.evtsExt__VoiceRecognition__RetrievetResultText.userFunc0x73c578(runtimeScene, typeof eventsFunctionContext !== 'undefined' ? eventsFunctionContext : undefined); + +} + + +}; + +gdjs.evtsExt__VoiceRecognition__RetrievetResultText.func = function(runtimeScene, parentEventsFunctionContext) { +var eventsFunctionContext = { + _objectsMap: { +}, + _objectArraysMap: { +}, + _behaviorNamesMap: { +}, + globalVariablesForExtension: runtimeScene.getGame().getVariablesForExtension("VoiceRecognition"), + sceneVariablesForExtension: runtimeScene.getScene().getVariablesForExtension("VoiceRecognition"), + localVariables: [], + getObjects: function(objectName) { + return eventsFunctionContext._objectArraysMap[objectName] || []; + }, + getObjectsLists: function(objectName) { + return eventsFunctionContext._objectsMap[objectName] || null; + }, + getBehaviorName: function(behaviorName) { + return eventsFunctionContext._behaviorNamesMap[behaviorName] || behaviorName; + }, + createObject: function(objectName) { + const objectsList = eventsFunctionContext._objectsMap[objectName]; + if (objectsList) { + const object = parentEventsFunctionContext ? + parentEventsFunctionContext.createObject(objectsList.firstKey()) : + runtimeScene.createObject(objectsList.firstKey()); + if (object) { + objectsList.get(objectsList.firstKey()).push(object); + eventsFunctionContext._objectArraysMap[objectName].push(object); + } + return object; } + return null; + }, + getInstancesCountOnScene: function(objectName) { + const objectsList = eventsFunctionContext._objectsMap[objectName]; + let count = 0; + if (objectsList) { + for(const objectName in objectsList.items) + count += parentEventsFunctionContext ? +parentEventsFunctionContext.getInstancesCountOnScene(objectName) : + runtimeScene.getInstancesCountOnScene(objectName); + } + return count; + }, + getLayer: function(layerName) { + return runtimeScene.getLayer(layerName); + }, + getArgument: function(argName) { + return ""; + }, + getOnceTriggers: function() { return runtimeScene.getOnceTriggers(); } +}; + + +gdjs.evtsExt__VoiceRecognition__RetrievetResultText.eventsList0(runtimeScene, eventsFunctionContext); + + +return "" + eventsFunctionContext.returnValue; +} + +gdjs.evtsExt__VoiceRecognition__RetrievetResultText.registeredGdjsCallbacks = []; \ No newline at end of file diff --git a/gdjs-evtsext__voicerecognition__startlistening-func.js b/gdjs-evtsext__voicerecognition__startlistening-func.js new file mode 100644 index 0000000000000000000000000000000000000000..092d68944c1d8f5e589458c186172ac791f176f7 --- /dev/null +++ b/gdjs-evtsext__voicerecognition__startlistening-func.js @@ -0,0 +1,104 @@ + +if (typeof gdjs.evtsExt__VoiceRecognition__StartListening !== "undefined") { + gdjs.evtsExt__VoiceRecognition__StartListening.registeredGdjsCallbacks.forEach(callback => + gdjs._unregisterCallback(callback) + ); +} + +gdjs.evtsExt__VoiceRecognition__StartListening = {}; + + +gdjs.evtsExt__VoiceRecognition__StartListening.userFunc0x7e6cf8 = function GDJSInlineCode(runtimeScene, eventsFunctionContext) { +"use strict"; +const Language = eventsFunctionContext.getArgument("language"); + +if(Language.trim() != "") { + gdjs._extensionVoiceRecognition.setLanguage(Language); +} + +gdjs._extensionVoiceRecognition.startListening(); +}; +gdjs.evtsExt__VoiceRecognition__StartListening.eventsList0 = function(runtimeScene, eventsFunctionContext) { + +{ + + +let isConditionTrue_0 = false; +{ +} + +} + + +{ + + +gdjs.evtsExt__VoiceRecognition__StartListening.userFunc0x7e6cf8(runtimeScene, typeof eventsFunctionContext !== 'undefined' ? eventsFunctionContext : undefined); + +} + + +}; + +gdjs.evtsExt__VoiceRecognition__StartListening.func = function(runtimeScene, language, parentEventsFunctionContext) { +var eventsFunctionContext = { + _objectsMap: { +}, + _objectArraysMap: { +}, + _behaviorNamesMap: { +}, + globalVariablesForExtension: runtimeScene.getGame().getVariablesForExtension("VoiceRecognition"), + sceneVariablesForExtension: runtimeScene.getScene().getVariablesForExtension("VoiceRecognition"), + localVariables: [], + getObjects: function(objectName) { + return eventsFunctionContext._objectArraysMap[objectName] || []; + }, + getObjectsLists: function(objectName) { + return eventsFunctionContext._objectsMap[objectName] || null; + }, + getBehaviorName: function(behaviorName) { + return eventsFunctionContext._behaviorNamesMap[behaviorName] || behaviorName; + }, + createObject: function(objectName) { + const objectsList = eventsFunctionContext._objectsMap[objectName]; + if (objectsList) { + const object = parentEventsFunctionContext ? + parentEventsFunctionContext.createObject(objectsList.firstKey()) : + runtimeScene.createObject(objectsList.firstKey()); + if (object) { + objectsList.get(objectsList.firstKey()).push(object); + eventsFunctionContext._objectArraysMap[objectName].push(object); + } + return object; } + return null; + }, + getInstancesCountOnScene: function(objectName) { + const objectsList = eventsFunctionContext._objectsMap[objectName]; + let count = 0; + if (objectsList) { + for(const objectName in objectsList.items) + count += parentEventsFunctionContext ? +parentEventsFunctionContext.getInstancesCountOnScene(objectName) : + runtimeScene.getInstancesCountOnScene(objectName); + } + return count; + }, + getLayer: function(layerName) { + return runtimeScene.getLayer(layerName); + }, + getArgument: function(argName) { +if (argName === "language") return language; + return ""; + }, + getOnceTriggers: function() { return runtimeScene.getOnceTriggers(); } +}; + + +gdjs.evtsExt__VoiceRecognition__StartListening.eventsList0(runtimeScene, eventsFunctionContext); + + +return; +} + +gdjs.evtsExt__VoiceRecognition__StartListening.registeredGdjsCallbacks = []; \ No newline at end of file diff --git a/howler-sound-manager/howler-sound-manager.js b/howler-sound-manager/howler-sound-manager.js new file mode 100644 index 0000000000000000000000000000000000000000..10a49ab6fec7d673e224595cb0e71efcb6a9603d --- /dev/null +++ b/howler-sound-manager/howler-sound-manager.js @@ -0,0 +1,2 @@ +var gdjs;(function(a){const h=new a.Logger("Audio manager"),f=["audio"],c={preload:!0,onplayerror:(u,e)=>h.error("Can't play an audio file: "+e),onloaderror:(u,e)=>h.error("Error while loading an audio file: "+e)},d=u=>u>1?1:u<0?0:u;class g{constructor(e,s,t,o){this._id=null;this._oncePlay=[];this._onPlay=[];this._howl=e,this._initialVolume=d(s),this._loop=t,this._rate=o}isLoaded(){return this._howl.state()==="loaded"}play(){if(this.isLoaded()){const e=this._howl.play(this._id===null?"__default":this._id);this._id=e,this._howl.volume(this._initialVolume,e),this._howl.loop(this._loop,e),this._howl.rate(a.HowlerSoundManager.clampRate(this._rate),e),this._onPlay.forEach(s=>{this.on("play",s),s(e)}),this._oncePlay.forEach(s=>s(e)),this._onPlay=[],this._oncePlay=[]}else this._howl.once("load",()=>this.play());return this}pause(){return this._id!==null&&this._howl.pause(this._id),this}stop(){return this._id!==null&&this._howl.stop(this._id),this}playing(){return(this._id!==null?this._howl.playing(this._id):!0)||!this.isLoaded()}paused(){return!this.playing()}stopped(){return this.paused()&&this.getSeek()===0}getRate(){return this._rate}setRate(e){return this._rate=e,this._id!==null&&(e=a.HowlerSoundManager.clampRate(e),this._howl.rate(e,this._id)),this}getLoop(){return this._loop}setLoop(e){return this._loop=e,this._id!==null&&this._howl.loop(e,this._id),this}getVolume(){return this._id===null?this._initialVolume:this._howl.volume(this._id)}setVolume(e){return this._initialVolume=d(e),this._id!==null&&this._howl.volume(this._initialVolume,this._id),this}getMute(){return this._id===null?!1:this._howl.mute(this._id)}setMute(e){return this._id!==null&&this._howl.mute(e,this._id),this}getSeek(){return this._id===null?0:this._howl.seek(this._id)}setSeek(e){return this._id!==null&&this._howl.seek(e,this._id),this}getSpatialPosition(e){return this._id===null?0:this._howl.pos(this._id)[e==="x"?0:e==="y"?1:2]}setSpatialPosition(e,s,t){return this._id!==null&&this._howl.pos(e,s,t,this._id),this}fade(e,s,t){return this._id!==null&&this._howl.fade(d(e),d(s),t,this._id),this}on(e,s){return e==="play"?this._id===null?this._onPlay.push(s):this._howl.on(e,s,this._id):this._id===null?this.once("play",()=>this.on(e,s)):this._howl.on(e,s,this._id),this}once(e,s){return e==="play"?this._id===null?this._oncePlay.push(s):this.playing()?s(this._id):this._howl.once(e,s,this._id):this._id===null?this.once("play",()=>this.once(e,s)):this._howl.once(e,s,this._id),this}off(e,s){return this._id!==null&&this._howl.off(e,s,this._id),this}}a.HowlerSound=g;class p{constructor(e){this._loadedMusics=new a.ResourceCache;this._loadedSounds=new a.ResourceCache;this._availableResources={};this._globalVolume=100;this._sounds={};this._musics={};this._freeSounds=[];this._freeMusics=[];this._pausedSounds=[];this._paused=!1;this._getAudioResource=e=>{const s=this._resourceLoader.getResource(e);return s&&this.getResourceKinds().includes(s.kind)?s:{file:e,kind:"audio",metadata:"",name:e}};this._resourceLoader=e;const s=this;document.addEventListener("deviceready",function(){document.addEventListener("pause",function(){const t=s._freeSounds.concat(s._freeMusics);for(let o in s._sounds)s._sounds.hasOwnProperty(o)&&t.push(s._sounds[o]);for(let o in s._musics)s._musics.hasOwnProperty(o)&&t.push(s._musics[o]);for(let o=0;o4?4:e<.5?.5:e}_storeSoundInArray(e,s){for(let t=0,o=e.length;t{this._paused&&(i.pause(),this._pausedSounds.push(i))}),i.play()}playSoundOnChannel(e,s,t,o,i){this._sounds[s]&&this._sounds[s].stop();const l=this.createHowlerSound(e,!1,o/100,t,i);this._sounds[s]=l,l.once("play",()=>{this._paused&&(l.pause(),this._pausedSounds.push(l))}),l.play()}getSoundOnChannel(e){return this._sounds[e]||null}playMusic(e,s,t,o){const i=this.createHowlerSound(e,!0,t/100,s,o);this._storeSoundInArray(this._freeMusics,i),i.once("play",()=>{this._paused&&(i.pause(),this._pausedSounds.push(i))}),i.play()}playMusicOnChannel(e,s,t,o,i){this._musics[s]&&this._musics[s].stop();const l=this.createHowlerSound(e,!0,o/100,t,i);this._musics[s]=l,l.once("play",()=>{this._paused&&(l.pause(),this._pausedSounds.push(l))}),l.play()}getMusicOnChannel(e){return this._musics[e]||null}setGlobalVolume(e){this._globalVolume=e,this._globalVolume>100&&(this._globalVolume=100),this._globalVolume<0&&(this._globalVolume=0),Howler.volume(this._globalVolume/100)}getGlobalVolume(){return this._globalVolume}clearAll(){Howler.stop(),this._freeSounds.length=0,this._freeMusics.length=0,this._sounds={},this._musics={},this._pausedSounds.length=0}async processResource(e){}async loadResource(e){const s=this._resourceLoader.getResource(e);if(!s){h.warn('Unable to find audio for resource "'+e+'".');return}if(s.file){if(this._availableResources[s.name])return;this._availableResources[s.name]=s}const t=(i,l)=>new Promise((r,n)=>{const _=l?this._loadedMusics:this._loadedSounds;_[i]=new Howl(Object.assign({},c,{src:[this._resourceLoader.getFullUrl(i)],onload:r,onloaderror:(y,w)=>n(w),html5:l,xhr:{withCredentials:this._resourceLoader.checkIfCredentialsRequired(i)},volume:0}))}),o=s.file;if(s.preloadAsMusic)try{await t(o,!0)}catch(i){h.warn("There was an error while preloading an audio file: "+i)}if(s.preloadAsSound)try{await t(o,!1)}catch(i){h.warn("There was an error while preloading an audio file: "+i)}else if(s.preloadInCache||!s.preloadAsMusic)try{await new Promise((i,l)=>{const r=new XMLHttpRequest;r.withCredentials=this._resourceLoader.checkIfCredentialsRequired(o),r.addEventListener("load",i),r.addEventListener("error",n=>l("XHR error: "+o)),r.addEventListener("abort",n=>l("XHR abort: "+o)),r.open("GET",this._resourceLoader.getFullUrl(o)),r.send()})}catch(i){h.warn("There was an error while preloading an audio file: "+i)}}dispose(){this.unloadAll()}}a.HowlerSoundManager=p,a.SoundManager=p})(gdjs||(gdjs={})); +//# sourceMappingURL=howler-sound-manager.js.map diff --git a/howler-sound-manager/howler.min.js b/howler-sound-manager/howler.min.js new file mode 100644 index 0000000000000000000000000000000000000000..c03115066ec33ea643bced02ec89a7aac150ee2a --- /dev/null +++ b/howler-sound-manager/howler.min.js @@ -0,0 +1,3 @@ +/*! howler.js v2.2.3 | (c) 2013-2020, James Simpson of GoldFire Studios | MIT License | howlerjs.com */ +/* Modified for GDevelop by reverting commit 0323af9b843351cacc47893aed8e65cd8ba3b0cb to fix https://github.com/goldfire/howler.js/issues/1603 */ +!function(){"use strict";var e=function(){this.init()};e.prototype={init:function(){var e=this||n;return e._counter=1e3,e._html5AudioPool=[],e.html5PoolSize=10,e._codecs={},e._howls=[],e._muted=!1,e._volume=1,e._canPlayEvent="canplaythrough",e._navigator="undefined"!=typeof window&&window.navigator?window.navigator:null,e.masterGain=null,e.noAudio=!1,e.usingWebAudio=!0,e.autoSuspend=!0,e.ctx=null,e.autoUnlock=!0,e._setup(),e},volume:function(e){var o=this||n;if(e=parseFloat(e),o.ctx||_(),void 0!==e&&e>=0&&e<=1){if(o._volume=e,o._muted)return o;o.usingWebAudio&&o.masterGain.gain.setValueAtTime(e,n.ctx.currentTime);for(var t=0;t=0;o--)e._howls[o].unload();return e.usingWebAudio&&e.ctx&&void 0!==e.ctx.close&&(e.ctx.close(),e.ctx=null,_()),e},codecs:function(e){return(this||n)._codecs[e.replace(/^x-/,"")]},_setup:function(){var e=this||n;if(e.state=e.ctx?e.ctx.state||"suspended":"suspended",e._autoSuspend(),!e.usingWebAudio)if("undefined"!=typeof Audio)try{var o=new Audio;void 0===o.oncanplaythrough&&(e._canPlayEvent="canplay")}catch(n){e.noAudio=!0}else e.noAudio=!0;try{var o=new Audio;o.muted&&(e.noAudio=!0)}catch(e){}return e.noAudio||e._setupCodecs(),e},_setupCodecs:function(){var e=this||n,o=null;try{o="undefined"!=typeof Audio?new Audio:null}catch(n){return e}if(!o||"function"!=typeof o.canPlayType)return e;var t=o.canPlayType("audio/mpeg;").replace(/^no$/,""),r=e._navigator?e._navigator.userAgent:"",a=r.match(/OPR\/([0-6].)/g),u=a&&parseInt(a[0].split("/")[1],10)<33,d=-1!==r.indexOf("Safari")&&-1===r.indexOf("Chrome"),i=r.match(/Version\/(.*?) /),_=d&&i&&parseInt(i[1],10)<15;return e._codecs={mp3:!(u||!t&&!o.canPlayType("audio/mp3;").replace(/^no$/,"")),mpeg:!!t,opus:!!o.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,""),ogg:!!o.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),oga:!!o.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),wav:!!(o.canPlayType('audio/wav; codecs="1"')||o.canPlayType("audio/wav")).replace(/^no$/,""),aac:!!o.canPlayType("audio/aac;").replace(/^no$/,""),caf:!!o.canPlayType("audio/x-caf;").replace(/^no$/,""),m4a:!!(o.canPlayType("audio/x-m4a;")||o.canPlayType("audio/m4a;")||o.canPlayType("audio/aac;")).replace(/^no$/,""),m4b:!!(o.canPlayType("audio/x-m4b;")||o.canPlayType("audio/m4b;")||o.canPlayType("audio/aac;")).replace(/^no$/,""),mp4:!!(o.canPlayType("audio/x-mp4;")||o.canPlayType("audio/mp4;")||o.canPlayType("audio/aac;")).replace(/^no$/,""),weba:!(_||!o.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),webm:!(_||!o.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),dolby:!!o.canPlayType('audio/mp4; codecs="ec-3"').replace(/^no$/,""),flac:!!(o.canPlayType("audio/x-flac;")||o.canPlayType("audio/flac;")).replace(/^no$/,"")},e},_unlockAudio:function(){var e=this||n;if(!e._audioUnlocked&&e.ctx){e._audioUnlocked=!1,e.autoUnlock=!1,e._mobileUnloaded||44100===e.ctx.sampleRate||(e._mobileUnloaded=!0,e.unload()),e._scratchBuffer=e.ctx.createBuffer(1,1,22050);var o=function(n){for(;e._html5AudioPool.length0?d._seek:t._sprite[e][0]/1e3),s=Math.max(0,(t._sprite[e][0]+t._sprite[e][1])/1e3-_),l=1e3*s/Math.abs(d._rate),c=t._sprite[e][0]/1e3,f=(t._sprite[e][0]+t._sprite[e][1])/1e3;d._sprite=e,d._ended=!1;var p=function(){d._paused=!1,d._seek=_,d._start=c,d._stop=f,d._loop=!(!d._loop&&!t._sprite[e][2])};if(_>=f)return void t._ended(d);var m=d._node;if(t._webAudio){var v=function(){t._playLock=!1,p(),t._refreshBuffer(d);var e=d._muted||t._muted?0:d._volume;m.gain.setValueAtTime(e,n.ctx.currentTime),d._playStart=n.ctx.currentTime,void 0===m.bufferSource.start?d._loop?m.bufferSource.noteGrainOn(0,_,86400):m.bufferSource.noteGrainOn(0,_,s):d._loop?m.bufferSource.start(0,_,86400):m.bufferSource.start(0,_,s),l!==1/0&&(t._endTimers[d._id]=setTimeout(t._ended.bind(t,d),l)),o||setTimeout(function(){t._emit("play",d._id),t._loadQueue()},0)};"running"===n.state&&"interrupted"!==n.ctx.state?v():(t._playLock=!0,t.once("resume",v),t._clearTimer(d._id))}else{var h=function(){m.currentTime=_,m.muted=d._muted||t._muted||n._muted||m.muted,m.volume=d._volume*n.volume(),m.playbackRate=d._rate;try{var r=m.play();if(r&&"undefined"!=typeof Promise&&(r instanceof Promise||"function"==typeof r.then)?(t._playLock=!0,p(),r.then(function(){t._playLock=!1,m._unlocked=!0,o||(t._emit("play",d._id),t._loadQueue())}).catch(function(){t._playLock=!1,t._emit("playerror",d._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction."),d._ended=!0,d._paused=!0})):o||(t._playLock=!1,p(),t._emit("play",d._id),t._loadQueue()),m.playbackRate=d._rate,m.paused)return void t._emit("playerror",d._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction.");"__default"!==e||d._loop?t._endTimers[d._id]=setTimeout(t._ended.bind(t,d),l):(t._endTimers[d._id]=function(){t._ended(d),m.removeEventListener("ended",t._endTimers[d._id],!1)},m.addEventListener("ended",t._endTimers[d._id],!1))}catch(e){t._emit("playerror",d._id,e)}};"data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA"===m.src&&(m.src=t._src,m.load());var y=window&&window.ejecta||!m.readyState&&n._navigator.isCocoonJS;if(m.readyState>=3||y)h();else{t._playLock=!0,t._state="loading";var g=function(){t._state="loaded",h(),m.removeEventListener(n._canPlayEvent,g,!1)};m.addEventListener(n._canPlayEvent,g,!1),t._clearTimer(d._id)}}return d._id},pause:function(e){var n=this;if("loaded"!==n._state||n._playLock)return n._queue.push({event:"pause",action:function(){n.pause(e)}}),n;for(var o=n._getSoundIds(e),t=0;t=0?o=parseInt(r[0],10):e=parseFloat(r[0])}else r.length>=2&&(e=parseFloat(r[0]),o=parseInt(r[1],10));var a;if(!(void 0!==e&&e>=0&&e<=1))return a=o?t._soundById(o):t._sounds[0],a?a._volume:0;if("loaded"!==t._state||t._playLock)return t._queue.push({event:"volume",action:function(){t.volume.apply(t,r)}}),t;void 0===o&&(t._volume=e),o=t._getSoundIds(o);for(var u=0;u0?t/_:t),l=Date.now();e._fadeTo=o,e._interval=setInterval(function(){var r=(Date.now()-l)/t;l=Date.now(),d+=i*r,d=Math.round(100*d)/100,d=i<0?Math.max(o,d):Math.min(o,d),u._webAudio?e._volume=d:u.volume(d,e._id,!0),a&&(u._volume=d),(on&&d>=o)&&(clearInterval(e._interval),e._interval=null,e._fadeTo=null,u.volume(o,e._id),u._emit("fade",e._id))},s)},_stopFade:function(e){var o=this,t=o._soundById(e);return t&&t._interval&&(o._webAudio&&t._node.gain.cancelScheduledValues(n.ctx.currentTime),clearInterval(t._interval),t._interval=null,o.volume(t._fadeTo,e),t._fadeTo=null,o._emit("fade",e)),o},loop:function(){var e,n,o,t=this,r=arguments;if(0===r.length)return t._loop;if(1===r.length){if("boolean"!=typeof r[0])return!!(o=t._soundById(parseInt(r[0],10)))&&o._loop;e=r[0],t._loop=e}else 2===r.length&&(e=r[0],n=parseInt(r[1],10));for(var a=t._getSoundIds(n),u=0;u=0?o=parseInt(r[0],10):e=parseFloat(r[0])}else 2===r.length&&(e=parseFloat(r[0]),o=parseInt(r[1],10));var d;if("number"!=typeof e)return d=t._soundById(o),d?d._rate:t._rate;if("loaded"!==t._state||t._playLock)return t._queue.push({event:"rate",action:function(){t.rate.apply(t,r)}}),t;void 0===o&&(t._rate=e),o=t._getSoundIds(o);for(var i=0;i=0?o=parseInt(r[0],10):t._sounds.length&&(o=t._sounds[0]._id,e=parseFloat(r[0]))}else 2===r.length&&(e=parseFloat(r[0]),o=parseInt(r[1],10));if(void 0===o)return 0;if("number"==typeof e&&("loaded"!==t._state||t._playLock))return t._queue.push({event:"seek",action:function(){t.seek.apply(t,r)}}),t;var d=t._soundById(o);if(d){if(!("number"==typeof e&&e>=0)){if(t._webAudio){var i=t.playing(o)?n.ctx.currentTime-d._playStart:0,_=d._rateSeek?d._rateSeek-d._seek:0;return d._seek+(_+i*Math.abs(d._rate))}return d._node.currentTime}var s=t.playing(o);s&&t.pause(o,!0),d._seek=e,d._ended=!1,t._clearTimer(o),t._webAudio||!d._node||isNaN(d._node.duration)||(d._node.currentTime=e);var l=function(){t._emit("seek",o),s&&t.play(o,!0)};if(s&&!t._webAudio){var c=function(){t._playLock?setTimeout(c,0):l()};setTimeout(c,0)}else l()}return t},playing:function(e){var n=this;if("number"==typeof e){var o=n._soundById(e);return!!o&&!o._paused}for(var t=0;t=0&&n._howls.splice(a,1);var u=!0;for(t=0;t=0){u=!1;break}return r&&u&&delete r[e._src],n.noAudio=!1,e._state="unloaded",e._sounds=[],e=null,null},on:function(e,n,o,t){var r=this,a=r["_on"+e];return"function"==typeof n&&a.push(t?{id:o,fn:n,once:t}:{id:o,fn:n}),r},off:function(e,n,o){var t=this,r=t["_on"+e],a=0;if("number"==typeof n&&(o=n,n=null),n||o)for(a=0;a=0;a--)r[a].id&&r[a].id!==n&&"load"!==e||(setTimeout(function(e){e.call(this,n,o)}.bind(t,r[a].fn),0),r[a].once&&t.off(e,r[a].fn,r[a].id));return t._loadQueue(e),t},_loadQueue:function(e){var n=this;if(n._queue.length>0){var o=n._queue[0];o.event===e&&(n._queue.shift(),n._loadQueue()),e||o.action()}return n},_ended:function(e){var o=this,t=e._sprite;if(!o._webAudio&&e._node&&!e._node.paused&&!e._node.ended&&e._node.currentTime=0;t--){if(o<=n)return;e._sounds[t]._ended&&(e._webAudio&&e._sounds[t]._node&&e._sounds[t]._node.disconnect(0),e._sounds.splice(t,1),o--)}}},_getSoundIds:function(e){var n=this;if(void 0===e){for(var o=[],t=0;t=0;if(n._scratchBuffer&&e.bufferSource&&(e.bufferSource.onended=null,e.bufferSource.disconnect(0),t))try{e.bufferSource.buffer=n._scratchBuffer}catch(e){}return e.bufferSource=null,o},_clearSound:function(e){/MSIE |Trident\//.test(n._navigator&&n._navigator.userAgent)||(e.src="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA")}};var t=function(e){this._parent=e,this.init()};t.prototype={init:function(){var e=this,o=e._parent;return e._muted=o._muted,e._loop=o._loop,e._volume=o._volume,e._rate=o._rate,e._seek=0,e._paused=!0,e._ended=!0,e._sprite="__default",e._id=++n._counter,o._sounds.push(e),e.create(),e},create:function(){var e=this,o=e._parent,t=n._muted||e._muted||e._parent._muted?0:e._volume;return o._webAudio?(e._node=void 0===n.ctx.createGain?n.ctx.createGainNode():n.ctx.createGain(),e._node.gain.setValueAtTime(t,n.ctx.currentTime),e._node.paused=!0,e._node.connect(n.masterGain)):n.noAudio||(e._node=n._obtainHtml5Audio(),e._errorFn=e._errorListener.bind(e),e._node.addEventListener("error",e._errorFn,!1),e._loadFn=e._loadListener.bind(e),e._node.addEventListener(n._canPlayEvent,e._loadFn,!1),e._endFn=e._endListener.bind(e),e._node.addEventListener("ended",e._endFn,!1),e._node.src=o._src,e._node.preload=!0===o._preload?"auto":o._preload,e._node.volume=t*n.volume(),e._node.load()),e},reset:function(){var e=this,o=e._parent;return e._muted=o._muted,e._loop=o._loop,e._volume=o._volume,e._rate=o._rate,e._seek=0,e._rateSeek=0,e._paused=!0,e._ended=!0,e._sprite="__default",e._id=++n._counter,e},_errorListener:function(){var e=this;e._parent._emit("loaderror",e._id,e._node.error?e._node.error.code:0),e._node.removeEventListener("error",e._errorFn,!1)},_loadListener:function(){var e=this,o=e._parent;o._duration=Math.ceil(10*e._node.duration)/10,0===Object.keys(o._sprite).length&&(o._sprite={__default:[0,1e3*o._duration]}),"loaded"!==o._state&&(o._state="loaded",o._emit("load"),o._loadQueue()),e._node.removeEventListener(n._canPlayEvent,e._loadFn,!1)},_endListener:function(){var e=this,n=e._parent;n._duration===1/0&&(n._duration=Math.ceil(10*e._node.duration)/10,n._sprite.__default[1]===1/0&&(n._sprite.__default[1]=1e3*n._duration),n._ended(e)),e._node.removeEventListener("ended",e._endFn,!1)}};var r={},a=function(e){var n=e._src;if(r[n])return e._duration=r[n].duration,void i(e);if(/^data:[^;]+;base64,/.test(n)){for(var o=atob(n.split(",")[1]),t=new Uint8Array(o.length),a=0;a0?(r[o._src]=e,i(o,e)):t()};"undefined"!=typeof Promise&&1===n.ctx.decodeAudioData.length?n.ctx.decodeAudioData(e).then(a).catch(t):n.ctx.decodeAudioData(e,a,t)},i=function(e,n){n&&!e._duration&&(e._duration=n.duration),0===Object.keys(e._sprite).length&&(e._sprite={__default:[0,1e3*e._duration]}),"loaded"!==e._state&&(e._state="loaded",e._emit("load"),e._loadQueue())},_=function(){if(n.usingWebAudio){try{"undefined"!=typeof AudioContext?n.ctx=new AudioContext:"undefined"!=typeof webkitAudioContext?n.ctx=new webkitAudioContext:n.usingWebAudio=!1}catch(e){n.usingWebAudio=!1}n.ctx||(n.usingWebAudio=!1);var e=/iP(hone|od|ad)/.test(n._navigator&&n._navigator.platform),o=n._navigator&&n._navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/),t=o?parseInt(o[1],10):null;if(e&&t&&t<9){var r=/safari/.test(n._navigator&&n._navigator.userAgent.toLowerCase());n._navigator&&!r&&(n.usingWebAudio=!1)}n.usingWebAudio&&(n.masterGain=void 0===n.ctx.createGain?n.ctx.createGainNode():n.ctx.createGain(),n.masterGain.gain.setValueAtTime(n._muted?0:n._volume,n.ctx.currentTime),n.masterGain.connect(n.ctx.destination)),n._setup()}};"function"==typeof define&&define.amd&&define([],function(){return{Howler:n,Howl:o}}),"undefined"!=typeof exports&&(exports.Howler=n,exports.Howl=o),"undefined"!=typeof global?(global.HowlerGlobal=e,global.Howler=n,global.Howl=o,global.Sound=t):"undefined"!=typeof window&&(window.HowlerGlobal=e,window.Howler=n,window.Howl=o,window.Sound=t)}(); diff --git a/index.html b/index.html index b0c4b3666032a737f3903db53e6a8a9272483e28..08463e28da0cc307343a4fbaac8b7d9fcf192db3 100644 --- a/index.html +++ b/index.html @@ -1,19 +1,135 @@ - + - - - - My static Space - - - -
-

Welcome to your static Space!

-

You can modify this app directly by editing index.html in the Files and versions tab.

-

- Also don't forget to check the - Spaces documentation. -

-
- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/inputmanager.js b/inputmanager.js new file mode 100644 index 0000000000000000000000000000000000000000..4e8d1bc167ba01661aaf26bbffc4d62d48d0560d --- /dev/null +++ b/inputmanager.js @@ -0,0 +1,2 @@ +var gdjs;(function(i){const o=class{constructor(){this._lastPressedKey=0;this._cursorX=0;this._cursorY=0;this._mouseX=0;this._mouseY=0;this._isMouseInsideCanvas=!0;this._mouseWheelDelta=0;this._touches={firstKey:()=>{for(const e in this._mouseOrTouches.items)if(e!=="1")return e;return null}};this._startedTouches=[];this._endedTouches=[];this._touchSimulateMouse=!0;this._lastStartedTouchIndex=0;this._lastEndedTouchIndex=0;this._pressedKeys=new Hashtable,this._releasedKeys=new Hashtable,this._pressedMouseButtons=new Array(5),this._releasedMouseButtons=new Array(5),this._mouseOrTouches=new Hashtable}_getLocationAwareKeyCode(e,s){return s?96<=e&&e<=105?e:e+1e3*s:o._DEFAULT_LEFT_VARIANT_KEYS.indexOf(e)!==-1?e+1e3:e}onKeyPressed(e,s){const t=this._getLocationAwareKeyCode(e,s);this._pressedKeys.put(t,!0),this._lastPressedKey=t}onKeyReleased(e,s){const t=this._getLocationAwareKeyCode(e,s);this._pressedKeys.put(t,!1),this._releasedKeys.put(t,!0)}getLastPressedKey(){return this._lastPressedKey}isKeyPressed(e){return this._pressedKeys.containsKey(e)&&this._pressedKeys.get(e)}wasKeyReleased(e){return this._releasedKeys.containsKey(e)&&this._releasedKeys.get(e)}anyKeyPressed(){for(const e in this._pressedKeys.items)if(this._pressedKeys.items.hasOwnProperty(e)&&this._pressedKeys.items[e])return!0;return!1}anyKeyReleased(){for(const e in this._releasedKeys.items)if(this._releasedKeys.items.hasOwnProperty(e)&&this._releasedKeys.items[e])return!0;return!1}onMouseMove(e,s){this._setCursorPosition(e,s),this._mouseX=e,this._mouseY=s,this.isMouseButtonPressed(o.MOUSE_LEFT_BUTTON)&&this._moveTouch(o.MOUSE_TOUCH_ID,this.getCursorX(),this.getCursorY())}_setCursorPosition(e,s){this._cursorX=e,this._cursorY=s}getCursorX(){return this._cursorX}getCursorY(){return this._cursorY}getMouseX(){return this._mouseX}getMouseY(){return this._mouseY}onMouseLeave(){this._isMouseInsideCanvas=!1}onMouseEnter(){this._isMouseInsideCanvas=!0}isMouseInsideCanvas(){return this._isMouseInsideCanvas}onMouseButtonPressed(e){this._setMouseButtonPressed(e),e===o.MOUSE_LEFT_BUTTON&&this._addTouch(o.MOUSE_TOUCH_ID,this.getCursorX(),this.getCursorY())}_setMouseButtonPressed(e){this._pressedMouseButtons[e]=!0,this._releasedMouseButtons[e]=!1}onMouseButtonReleased(e){this._setMouseButtonReleased(e),e===o.MOUSE_LEFT_BUTTON&&this._removeTouch(o.MOUSE_TOUCH_ID)}_setMouseButtonReleased(e){this._pressedMouseButtons[e]=!1,this._releasedMouseButtons[e]=!0}isMouseButtonPressed(e){return this._pressedMouseButtons[e]!==void 0&&this._pressedMouseButtons[e]}isMouseButtonReleased(e){return this._releasedMouseButtons[e]!==void 0&&this._releasedMouseButtons[e]}onMouseWheel(e){this._mouseWheelDelta=e}getMouseWheelDelta(){return this._mouseWheelDelta}getTouchX(e){return this._mouseOrTouches.containsKey(e)?this._mouseOrTouches.get(e).x:0}getTouchY(e){return this._mouseOrTouches.containsKey(e)?this._mouseOrTouches.get(e).y:0}hasTouchEnded(e){return this._mouseOrTouches.containsKey(e)?this._mouseOrTouches.get(e).justEnded:!1}getAllTouchIdentifiers(){o._allTouchIds.length=0;for(const e in this._mouseOrTouches.items)this._mouseOrTouches.items.hasOwnProperty(e)&&o._allTouchIds.push(parseInt(e,10));return o._allTouchIds}onTouchStart(e,s,t){this._addTouch(this.getPublicTouchIdentifier(e),s,t),this._touchSimulateMouse&&(this._setCursorPosition(s,t),this._setMouseButtonPressed(o.MOUSE_LEFT_BUTTON))}_addTouch(e,s,t){this._endedTouches.includes(e)||(this._startedTouches.push(e),this._mouseOrTouches.put(e,{x:s,y:t,justEnded:!1}))}onTouchMove(e,s,t){this._moveTouch(this.getPublicTouchIdentifier(e),s,t),this._touchSimulateMouse&&this._setCursorPosition(s,t)}_moveTouch(e,s,t){const u=this._mouseOrTouches.get(e);!u||(u.x=s,u.y=t)}onTouchEnd(e){this._removeTouch(this.getPublicTouchIdentifier(e)),this._touchSimulateMouse&&this._setMouseButtonReleased(o.MOUSE_LEFT_BUTTON)}onTouchCancel(e){this.onTouchEnd(e)}_removeTouch(e){this._endedTouches.push(e),this._mouseOrTouches.containsKey(e)&&(this._mouseOrTouches.get(e).justEnded=!0)}getPublicTouchIdentifier(e){return e+2}getStartedTouchIdentifiers(){return this._startedTouches}popStartedTouch(){const e=this._startedTouches[this._lastStartedTouchIndex];return this._lastStartedTouchIndex++,e}popEndedTouch(){const e=this._endedTouches[this._lastEndedTouchIndex];return this._lastEndedTouchIndex++,e}touchSimulateMouse(e){e===void 0&&(e=!0),this._touchSimulateMouse=e}isSimulatingMouseWithTouch(){return this._touchSimulateMouse}onFrameEnded(){for(const e in this._mouseOrTouches.items)this._mouseOrTouches.items.hasOwnProperty(e)&&this._mouseOrTouches.items[e].justEnded&&this._mouseOrTouches.remove(e);this._startedTouches.length=0,this._endedTouches.length=0,this._releasedKeys.clear(),this._releasedMouseButtons.length=0,this._mouseWheelDelta=0,this._lastStartedTouchIndex=0,this._lastEndedTouchIndex=0}isScrollingUp(){return this.getMouseWheelDelta()>0}isScrollingDown(){return this.getMouseWheelDelta()<0}clearAllPressedKeys(){this._pressedKeys.clear()}};let r=o;r.MOUSE_LEFT_BUTTON=0,r.MOUSE_RIGHT_BUTTON=1,r.MOUSE_MIDDLE_BUTTON=2,r.MOUSE_BACK_BUTTON=3,r.MOUSE_FORWARD_BUTTON=4,r.MOUSE_TOUCH_ID=1,r._DEFAULT_LEFT_VARIANT_KEYS=[16,17,18,91],r._allTouchIds=[],i.InputManager=r})(gdjs||(gdjs={})); +//# sourceMappingURL=inputmanager.js.map diff --git a/jsonmanager.js b/jsonmanager.js new file mode 100644 index 0000000000000000000000000000000000000000..1669e7b4833e5850f370b15a3368d666c2b2f9fd --- /dev/null +++ b/jsonmanager.js @@ -0,0 +1,2 @@ +var gdjs;(function(c){const l=new c.Logger("JSON Manager"),i=["json","tilemap","tileset"];class u{constructor(s){this._loadedJsons=new c.ResourceCache;this._callbacks=new c.ResourceCache;this._getJsonResource=s=>{const r=this._resourceLoader.getResource(s);return r&&this.getResourceKinds().includes(r.kind)?r:null};this._resourceLoader=s}getResourceKinds(){return i}async loadResource(s){const r=this._resourceLoader.getResource(s);if(!r){l.warn('Unable to find json for resource "'+s+'".');return}if(!r.disablePreload)try{await this.loadJsonAsync(r.name)}catch(e){l.error(`Error while preloading json resource ${r.name}:`,e)}}loadJsonAsync(s){const r=this;return new Promise((e,t)=>{r.loadJson(s,(o,n)=>{o&&t(o.message),e(n)})})}async processResource(s){}loadJson(s,r){const e=this._getJsonResource(s);if(!e){r(new Error(`Can't find resource with name: "`+s+'" (or is not a json resource).'),null);return}if(this._loadedJsons.get(e)){r(null,this._loadedJsons.get(e));return}{const n=this._callbacks.get(e);if(n){n.push(r);return}else this._callbacks.set(e,[r])}const t=this,o=new XMLHttpRequest;o.responseType="json",o.withCredentials=this._resourceLoader.checkIfCredentialsRequired(e.file),o.open("GET",this._resourceLoader.getFullUrl(e.file)),o.onload=function(){const n=t._callbacks.get(e);if(!!n){if(o.status!==200){for(const a of n)a(new Error("HTTP error: "+o.status+"("+o.statusText+")"),null);t._callbacks.delete(e);return}t._loadedJsons.set(e,o.response);for(const a of n)a(null,o.response);t._callbacks.delete(e)}},o.onerror=function(){const n=t._callbacks.get(e);if(!!n){for(const a of n)a(new Error("Network error"),null);t._callbacks.delete(e)}},o.onabort=function(){const n=t._callbacks.get(e);if(!!n){for(const a of n)a(new Error("Request aborted"),null);t._callbacks.delete(e)}},o.send()}isJsonLoaded(s){return!!this._loadedJsons.getFromName(s)}getLoadedJson(s){return this._loadedJsons.getFromName(s)||null}dispose(){this._loadedJsons.clear(),this._callbacks.clear()}}c.JsonManager=u})(gdjs||(gdjs={})); +//# sourceMappingURL=jsonmanager.js.map diff --git a/layer.js b/layer.js new file mode 100644 index 0000000000000000000000000000000000000000..d92bd6c1c942d53eb2c5ae3c222bd59f198d1eaf --- /dev/null +++ b/layer.js @@ -0,0 +1,2 @@ +var gdjs;(function(h){class c extends h.RuntimeLayer{constructor(t,e){super(t,e);this._cameraRotation=0;this._zoomFactor=1;this._cameraZ=0;this._isCameraZDirty=!0;this._defaultCameraBehavior===h.RuntimeLayerDefaultCameraBehavior.TOP_LEFT_ANCHORED_IF_NEVER_MOVED?(this._cameraX=this._runtimeScene.getViewportOriginX(),this._cameraY=this._runtimeScene.getViewportOriginY()):(this._cameraX=(this._runtimeScene.getInitialUnrotatedViewportMinX()+this._runtimeScene.getInitialUnrotatedViewportMaxX())/2,this._cameraY=(this._runtimeScene.getInitialUnrotatedViewportMinY()+this._runtimeScene.getInitialUnrotatedViewportMaxY())/2),this.getCameraType()===h.RuntimeLayerCameraType.ORTHOGRAPHIC&&(this._cameraZ=(this._initialCamera3DFarPlaneDistance+this._initialCamera3DNearPlaneDistance)/2),this._renderer.onCreated()}onGameResolutionResized(t,e){this._defaultCameraBehavior===h.RuntimeLayerDefaultCameraBehavior.TOP_LEFT_ANCHORED_IF_NEVER_MOVED&&Math.abs(this._cameraX-t)<1&&Math.abs(this._cameraY-e)<1&&this._zoomFactor===1&&(this._cameraX+=this._runtimeScene.getViewportOriginX()-t,this._cameraY+=this._runtimeScene.getViewportOriginY()-e),this._renderer.updatePosition(),this._renderer.updateResolution()}getCameraX(t){return this._forceDimensionUpdate(),this._cameraX}getCameraY(t){return this._forceDimensionUpdate(),this._cameraY}setCameraX(t,e){this._forceDimensionUpdate(),this._cameraX=t,this._renderer.updatePosition()}setCameraY(t,e){this._forceDimensionUpdate(),this._cameraY=t,this._renderer.updatePosition()}getCameraWidth(t){return this.getWidth()/this._zoomFactor}getCameraHeight(t){return this.getHeight()/this._zoomFactor}setCameraZoom(t,e){this._zoomFactor=t,this._isCameraZDirty=!0,this._renderer.updatePosition()}getCameraZoom(t){return this._zoomFactor}setCameraZ(t,e,i){if(e){const r=h.toRad(e),a=Math.min(Number.MAX_SAFE_INTEGER,.5*this.getHeight()/(t*Math.tan(.5*r)));a>0&&(this._zoomFactor=a)}this._cameraZ=t,this._isCameraZDirty=!1,this._renderer.updatePosition()}getCameraZ(t,e){return!this._isCameraZDirty||!t?this._cameraZ:.5*this.getHeight()/this.getCameraZoom()/Math.tan(.5*h.toRad(t))}getCameraRotation(t){return this._cameraRotation}setCameraRotation(t,e){this._cameraRotation=t,this._renderer.updatePosition()}convertCoords(t,e,i=0,r){let a=r||[0,0];if(this._renderer.isCameraRotatedIn3D())return this._renderer.transformTo3DWorld(t,e,0,i,r);t-=this.getRuntimeScene()._cachedGameResolutionWidth/2,e-=this.getRuntimeScene()._cachedGameResolutionHeight/2,t/=Math.abs(this._zoomFactor),e/=Math.abs(this._zoomFactor);const n=this._cameraRotation/180*Math.PI,s=t,o=Math.cos(n),m=Math.sin(n);return t=o*t-m*e,e=m*s+o*e,a[0]=t+this.getCameraX(i),a[1]=e+this.getCameraY(i),a}applyLayerInverseTransformation(t,e,i,r){t-=this._runtimeScene.getViewportOriginX(),e-=this._runtimeScene.getViewportOriginY(),t/=Math.abs(this._zoomFactor),e/=Math.abs(this._zoomFactor);const a=this._cameraRotation/180*Math.PI,n=t,s=Math.cos(a),o=Math.sin(a);return t=s*t-o*e,e=o*n+s*e,r[0]=t+this.getCameraX(i),r[1]=e+this.getCameraY(i),r}convertInverseCoords(t,e,i=0,r){let a=r||[0,0];t-=this.getCameraX(i),e-=this.getCameraY(i);const n=this._cameraRotation/180*Math.PI,s=t,o=Math.cos(-n),m=Math.sin(-n);return t=o*t-m*e,e=m*s+o*e,t*=Math.abs(this._zoomFactor),e*=Math.abs(this._zoomFactor),a[0]=t+this.getRuntimeScene()._cachedGameResolutionWidth/2,a[1]=e+this.getRuntimeScene()._cachedGameResolutionHeight/2,a}applyLayerTransformation(t,e,i,r){t-=this.getCameraX(i),e-=this.getCameraY(i);const a=this._cameraRotation/180*Math.PI,n=t,s=Math.cos(-a),o=Math.sin(-a);return t=s*t-o*e,e=o*n+s*e,t*=Math.abs(this._zoomFactor),e*=Math.abs(this._zoomFactor),t+=this._runtimeScene.getViewportOriginX(),e+=this._runtimeScene.getViewportOriginY(),r[0]=t,r[1]=e,r}_forceDimensionUpdate(){this._runtimeScene.getViewportWidth()}}h.Layer=c})(gdjs||(gdjs={})); +//# sourceMappingURL=layer.js.map diff --git a/libs/jshashtable.js b/libs/jshashtable.js new file mode 100644 index 0000000000000000000000000000000000000000..efef5628915d5e2c9ab9104d37bc6ea558d03436 --- /dev/null +++ b/libs/jshashtable.js @@ -0,0 +1,2 @@ +class Hashtable{constructor(){this.items={}}static newFrom(t){const s=new Hashtable;return s.items=t,s}put(t,s){this.items[t]=s}get(t){return this.items[t]}containsKey(t){return this.items.hasOwnProperty(t)}remove(t){delete this.items[t]}firstKey(){for(const t in this.items)if(this.items.hasOwnProperty(t))return t;return null}keys(t){t.length=0;for(const s in this.items)this.items.hasOwnProperty(s)&&t.push(s)}values(t){t.length=0;for(const s in this.items)this.items.hasOwnProperty(s)&&t.push(this.items[s])}clear(){for(const t in this.items)this.items.hasOwnProperty(t)&&delete this.items[t]}} +//# sourceMappingURL=jshashtable.js.map diff --git a/libs/rbush.js b/libs/rbush.js new file mode 100644 index 0000000000000000000000000000000000000000..96c70f1a4354b80801296c905a69cfc1d81adf96 --- /dev/null +++ b/libs/rbush.js @@ -0,0 +1,624 @@ +(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.rbush = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o= 0) { + if (insertPath[level].children.length > this._maxEntries) { + this._split(insertPath, level); + level--; + } else break; + } + + // adjust bboxes along the insertion path + this._adjustParentBBoxes(bbox, insertPath, level); + }, + + // split overflowed node into two + _split: function (insertPath, level) { + + var node = insertPath[level], + M = node.children.length, + m = this._minEntries; + + this._chooseSplitAxis(node, m, M); + + var splitIndex = this._chooseSplitIndex(node, m, M); + + var newNode = createNode(node.children.splice(splitIndex, node.children.length - splitIndex)); + newNode.height = node.height; + newNode.leaf = node.leaf; + + calcBBox(node, this.toBBox); + calcBBox(newNode, this.toBBox); + + if (level) insertPath[level - 1].children.push(newNode); + else this._splitRoot(node, newNode); + }, + + _splitRoot: function (node, newNode) { + // split root node + this.data = createNode([node, newNode]); + this.data.height = node.height + 1; + this.data.leaf = false; + calcBBox(this.data, this.toBBox); + }, + + _chooseSplitIndex: function (node, m, M) { + + var i, bbox1, bbox2, overlap, area, minOverlap, minArea, index; + + minOverlap = minArea = Infinity; + + for (i = m; i <= M - m; i++) { + bbox1 = distBBox(node, 0, i, this.toBBox); + bbox2 = distBBox(node, i, M, this.toBBox); + + overlap = intersectionArea(bbox1, bbox2); + area = bboxArea(bbox1) + bboxArea(bbox2); + + // choose distribution with minimum overlap + if (overlap < minOverlap) { + minOverlap = overlap; + index = i; + + minArea = area < minArea ? area : minArea; + + } else if (overlap === minOverlap) { + // otherwise choose distribution with minimum area + if (area < minArea) { + minArea = area; + index = i; + } + } + } + + return index; + }, + + // sorts node children by the best axis for split + _chooseSplitAxis: function (node, m, M) { + + var compareMinX = node.leaf ? this.compareMinX : compareNodeMinX, + compareMinY = node.leaf ? this.compareMinY : compareNodeMinY, + xMargin = this._allDistMargin(node, m, M, compareMinX), + yMargin = this._allDistMargin(node, m, M, compareMinY); + + // if total distributions margin value is minimal for x, sort by minX, + // otherwise it's already sorted by minY + if (xMargin < yMargin) node.children.sort(compareMinX); + }, + + // total margin of all possible split distributions where each node is at least m full + _allDistMargin: function (node, m, M, compare) { + + node.children.sort(compare); + + var toBBox = this.toBBox, + leftBBox = distBBox(node, 0, m, toBBox), + rightBBox = distBBox(node, M - m, M, toBBox), + margin = bboxMargin(leftBBox) + bboxMargin(rightBBox), + i, child; + + for (i = m; i < M - m; i++) { + child = node.children[i]; + extend(leftBBox, node.leaf ? toBBox(child) : child); + margin += bboxMargin(leftBBox); + } + + for (i = M - m - 1; i >= m; i--) { + child = node.children[i]; + extend(rightBBox, node.leaf ? toBBox(child) : child); + margin += bboxMargin(rightBBox); + } + + return margin; + }, + + _adjustParentBBoxes: function (bbox, path, level) { + // adjust bboxes along the given tree path + for (var i = level; i >= 0; i--) { + extend(path[i], bbox); + } + }, + + _condense: function (path) { + // go through the path, removing empty nodes and updating bboxes + for (var i = path.length - 1, siblings; i >= 0; i--) { + if (path[i].children.length === 0) { + if (i > 0) { + siblings = path[i - 1].children; + siblings.splice(siblings.indexOf(path[i]), 1); + + } else this.clear(); + + } else calcBBox(path[i], this.toBBox); + } + }, + + _initFormat: function (format) { + // data format (minX, minY, maxX, maxY accessors) + + // uses eval-type function compilation instead of just accepting a toBBox function + // because the algorithms are very sensitive to sorting functions performance, + // so they should be dead simple and without inner calls + + var compareArr = ['return a', ' - b', ';']; + + this.compareMinX = new Function('a', 'b', compareArr.join(format[0])); + this.compareMinY = new Function('a', 'b', compareArr.join(format[1])); + + this.toBBox = new Function('a', + 'return {minX: a' + format[0] + + ', minY: a' + format[1] + + ', maxX: a' + format[2] + + ', maxY: a' + format[3] + '};'); + } +}; + +function findItem(item, items, equalsFn) { + if (!equalsFn) return items.indexOf(item); + + for (var i = 0; i < items.length; i++) { + if (equalsFn(item, items[i])) return i; + } + return -1; +} + +// calculate node's bbox from bboxes of its children +function calcBBox(node, toBBox) { + distBBox(node, 0, node.children.length, toBBox, node); +} + +// min bounding rectangle of node children from k to p-1 +function distBBox(node, k, p, toBBox, destNode) { + if (!destNode) destNode = createNode(null); + destNode.minX = Infinity; + destNode.minY = Infinity; + destNode.maxX = -Infinity; + destNode.maxY = -Infinity; + + for (var i = k, child; i < p; i++) { + child = node.children[i]; + extend(destNode, node.leaf ? toBBox(child) : child); + } + + return destNode; +} + +function extend(a, b) { + a.minX = Math.min(a.minX, b.minX); + a.minY = Math.min(a.minY, b.minY); + a.maxX = Math.max(a.maxX, b.maxX); + a.maxY = Math.max(a.maxY, b.maxY); + return a; +} + +function compareNodeMinX(a, b) { return a.minX - b.minX; } +function compareNodeMinY(a, b) { return a.minY - b.minY; } + +function bboxArea(a) { return (a.maxX - a.minX) * (a.maxY - a.minY); } +function bboxMargin(a) { return (a.maxX - a.minX) + (a.maxY - a.minY); } + +function enlargedArea(a, b) { + return (Math.max(b.maxX, a.maxX) - Math.min(b.minX, a.minX)) * + (Math.max(b.maxY, a.maxY) - Math.min(b.minY, a.minY)); +} + +function intersectionArea(a, b) { + var minX = Math.max(a.minX, b.minX), + minY = Math.max(a.minY, b.minY), + maxX = Math.min(a.maxX, b.maxX), + maxY = Math.min(a.maxY, b.maxY); + + return Math.max(0, maxX - minX) * + Math.max(0, maxY - minY); +} + +function contains(a, b) { + return a.minX <= b.minX && + a.minY <= b.minY && + b.maxX <= a.maxX && + b.maxY <= a.maxY; +} + +function intersects(a, b) { + return b.minX <= a.maxX && + b.minY <= a.maxY && + b.maxX >= a.minX && + b.maxY >= a.minY; +} + +function createNode(children) { + return { + children: children, + height: 1, + leaf: true, + minX: Infinity, + minY: Infinity, + maxX: -Infinity, + maxY: -Infinity + }; +} + +// sort an array so that items come in groups of n unsorted items, with groups sorted between each other; +// combines selection algorithm with binary divide & conquer approach + +function multiSelect(arr, left, right, n, compare) { + var stack = [left, right], + mid; + + while (stack.length) { + right = stack.pop(); + left = stack.pop(); + + if (right - left <= n) continue; + + mid = left + Math.ceil((right - left) / n / 2) * n; + quickselect(arr, mid, left, right, compare); + + stack.push(left, mid, mid, right); + } +} + +},{"quickselect":2}],2:[function(require,module,exports){ +'use strict'; + +module.exports = partialSort; + +// Floyd-Rivest selection algorithm: +// Rearrange items so that all items in the [left, k] range are smaller than all items in (k, right]; +// The k-th element will have the (k - left + 1)th smallest value in [left, right] + +function partialSort(arr, k, left, right, compare) { + + while (right > left) { + if (right - left > 600) { + var n = right - left + 1; + var m = k - left + 1; + var z = Math.log(n); + var s = 0.5 * Math.exp(2 * z / 3); + var sd = 0.5 * Math.sqrt(z * s * (n - s) / n) * (m - n / 2 < 0 ? -1 : 1); + var newLeft = Math.max(left, Math.floor(k - m * s / n + sd)); + var newRight = Math.min(right, Math.floor(k + (n - m) * s / n + sd)); + partialSort(arr, k, newLeft, newRight, compare); + } + + var t = arr[k]; + var i = left; + var j = right; + + swap(arr, left, k); + if (compare(arr[right], t) > 0) swap(arr, left, right); + + while (i < j) { + swap(arr, i, j); + i++; + j--; + while (compare(arr[i], t) < 0) i++; + while (compare(arr[j], t) > 0) j--; + } + + if (compare(arr[left], t) === 0) swap(arr, left, j); + else { + j++; + swap(arr, j, right); + } + + if (j <= k) left = j + 1; + if (k <= j) right = j - 1; + } +} + +function swap(arr, i, j) { + var tmp = arr[i]; + arr[i] = arr[j]; + arr[j] = tmp; +} + +function defaultCompare(a, b) { + return a < b ? -1 : a > b ? 1 : 0; +} + +},{}]},{},[1])(1) +}); diff --git a/logger.js b/logger.js new file mode 100644 index 0000000000000000000000000000000000000000..98a4cf6e41f41ef05af09989f7d8b9683b5c7e2f --- /dev/null +++ b/logger.js @@ -0,0 +1,2 @@ +var gdjs;(function(l){const g={info:console.log,warning:console.warn,error:console.error};class i{constructor(){this.discardedConsoleGroups=new Set}discardGroup(o){this.discardedConsoleGroups.add(o)}enableGroup(o){this.discardedConsoleGroups.delete(o)}log(o,n,u="info",p=!0){if(this.discardedConsoleGroups.has(o))return;(g[u]||g.info)(`[${o}] ${n}`)}}const s=new i;let r=s;function t(e){return e.reduce((o,n)=>o+n.toString(),"")}class a{constructor(o){this.group=o}log(...o){r.log(this.group,t(o),"info")}info(...o){r.log(this.group,t(o),"info")}warn(...o){r.log(this.group,t(o),"warning")}error(...o){r.log(this.group,t(o),"error")}static getDefaultConsoleLoggerOutput(){return s}static getLoggerOutput(){return r}static setLoggerOutput(o){r=o}}l.Logger=a})(gdjs||(gdjs={})); +//# sourceMappingURL=logger.js.map diff --git a/manifest.webmanifest b/manifest.webmanifest new file mode 100644 index 0000000000000000000000000000000000000000..0f2c7c55f007832f99af2a208318e15acccafc10 --- /dev/null +++ b/manifest.webmanifest @@ -0,0 +1,12 @@ +{ + "name": "Fresh Winter (Voice recognition)", + "short_name": "Fresh Winter (Voice recognition)", + "id": "com.planktonfun.voicerecognition", + "description": "A demo for using voice recognition in gdevelop, useful for a developer looking to make voice based games/apps.", + "orientation": "landscape", + "start_url": "./index.html", + "display": "standalone", + "background_color": "black", + "categories": ["games", "entertainment"], + "icons": [] +} \ No newline at end of file diff --git a/object-capabilities/AnimatableBehavior.js b/object-capabilities/AnimatableBehavior.js new file mode 100644 index 0000000000000000000000000000000000000000..1e9b71c444d7ffc09fc55c348b4c2e28c3491ccc --- /dev/null +++ b/object-capabilities/AnimatableBehavior.js @@ -0,0 +1,2 @@ +var gdjs;(function(t){class a extends t.RuntimeBehavior{constructor(e,i,n){super(e,i,n);this.object=n}usesLifecycleFunction(){return!1}updateFromBehaviorData(e,i){return!0}onDeActivate(){}onDestroy(){}doStepPreEvents(e){}doStepPostEvents(e){}getAnimationIndex(){return this.object.getAnimationIndex()}setAnimationIndex(e){this.object.setAnimationIndex(e)}getAnimationName(){return this.object.getAnimationName()}setAnimationName(e){this.object.setAnimationName(e)}hasAnimationEnded(){return this.object.hasAnimationEnded()}isAnimationPaused(){return this.object.isAnimationPaused()}pauseAnimation(){this.object.pauseAnimation()}resumeAnimation(){this.object.resumeAnimation()}getAnimationSpeedScale(){return this.object.getAnimationSpeedScale()}setAnimationSpeedScale(e){this.object.setAnimationSpeedScale(e)}getAnimationElapsedTime(){return this.object.getAnimationElapsedTime()}setAnimationElapsedTime(e){this.object.setAnimationElapsedTime(e)}getAnimationDuration(){return this.object.getAnimationDuration()}}t.AnimatableBehavior=a,t.registerBehavior("AnimatableCapability::AnimatableBehavior",t.AnimatableBehavior)})(gdjs||(gdjs={})); +//# sourceMappingURL=AnimatableBehavior.js.map diff --git a/object-capabilities/EffectBehavior.js b/object-capabilities/EffectBehavior.js new file mode 100644 index 0000000000000000000000000000000000000000..0c6caf751f4740459b270e5066c5c9625dad4799 --- /dev/null +++ b/object-capabilities/EffectBehavior.js @@ -0,0 +1,2 @@ +var gdjs;(function(n){class r extends n.RuntimeBehavior{constructor(e,t,a){super(e,t,a);this.object=a}usesLifecycleFunction(){return!1}updateFromBehaviorData(e,t){return!0}onDeActivate(){}onDestroy(){}doStepPreEvents(e){}doStepPostEvents(e){}setEffectDoubleParameter(e,t,a){return this.object.setEffectDoubleParameter(e,t,a)}setEffectStringParameter(e,t,a){return this.object.setEffectStringParameter(e,t,a)}setEffectBooleanParameter(e,t,a){return this.object.setEffectBooleanParameter(e,t,a)}enableEffect(e,t){this.object.enableEffect(e,t)}isEffectEnabled(e){return this.object.isEffectEnabled(e)}}n.EffectBehavior=r,n.registerBehavior("EffectCapability::EffectBehavior",n.EffectBehavior)})(gdjs||(gdjs={})); +//# sourceMappingURL=EffectBehavior.js.map diff --git a/object-capabilities/FlippableBehavior.js b/object-capabilities/FlippableBehavior.js new file mode 100644 index 0000000000000000000000000000000000000000..d66137193d1b6928ec372b092df4c18fc89ce6ea --- /dev/null +++ b/object-capabilities/FlippableBehavior.js @@ -0,0 +1,2 @@ +var gdjs;(function(i){class a extends i.RuntimeBehavior{constructor(e,t,o){super(e,t,o);this.object=o}usesLifecycleFunction(){return!1}updateFromBehaviorData(e,t){return!0}onDeActivate(){}onDestroy(){}doStepPreEvents(e){}doStepPostEvents(e){}flipX(e){this.object.flipX(e)}flipY(e){this.object.flipY(e)}isFlippedX(){return this.object.isFlippedX()}isFlippedY(){return this.object.isFlippedY()}}i.FlippableBehavior=a,i.registerBehavior("FlippableCapability::FlippableBehavior",i.FlippableBehavior)})(gdjs||(gdjs={})); +//# sourceMappingURL=FlippableBehavior.js.map diff --git a/object-capabilities/OpacityBehavior.js b/object-capabilities/OpacityBehavior.js new file mode 100644 index 0000000000000000000000000000000000000000..dac793937645b7aa83f7baeb374171b8d20645c8 --- /dev/null +++ b/object-capabilities/OpacityBehavior.js @@ -0,0 +1,2 @@ +var gdjs;(function(e){class n extends e.RuntimeBehavior{constructor(t,a,i){super(t,a,i);this.object=i}usesLifecycleFunction(){return!1}updateFromBehaviorData(t,a){return!0}onDeActivate(){}onDestroy(){}doStepPreEvents(t){}doStepPostEvents(t){}setOpacity(t){this.object.setOpacity(t)}getOpacity(){return this.object.getOpacity()}}e.OpacityBehavior=n,e.registerBehavior("OpacityCapability::OpacityBehavior",e.OpacityBehavior)})(gdjs||(gdjs={})); +//# sourceMappingURL=OpacityBehavior.js.map diff --git a/object-capabilities/ResizableBehavior.js b/object-capabilities/ResizableBehavior.js new file mode 100644 index 0000000000000000000000000000000000000000..941b522a5841e065fdee9fb863fc70b3ef96e134 --- /dev/null +++ b/object-capabilities/ResizableBehavior.js @@ -0,0 +1,2 @@ +var gdjs;(function(i){class o extends i.RuntimeBehavior{constructor(e,t,a){super(e,t,a);this.object=a}usesLifecycleFunction(){return!1}updateFromBehaviorData(e,t){return!0}onDeActivate(){}onDestroy(){}doStepPreEvents(e){}doStepPostEvents(e){}setWidth(e){this.object.setWidth(e)}setHeight(e){this.object.setHeight(e)}setSize(e,t){this.object.setSize(e,t)}getWidth(){return this.object.getWidth()}getHeight(){return this.object.getHeight()}}i.ResizableBehavior=o,i.registerBehavior("ResizableCapability::ResizableBehavior",i.ResizableBehavior)})(gdjs||(gdjs={})); +//# sourceMappingURL=ResizableBehavior.js.map diff --git a/object-capabilities/ScalableBehavior.js b/object-capabilities/ScalableBehavior.js new file mode 100644 index 0000000000000000000000000000000000000000..b11bb21b49c1a003766a4ad9e9379dc38cb14f0d --- /dev/null +++ b/object-capabilities/ScalableBehavior.js @@ -0,0 +1,2 @@ +var gdjs;(function(t){class o extends t.RuntimeBehavior{constructor(e,a,l){super(e,a,l);this.object=l}usesLifecycleFunction(){return!1}updateFromBehaviorData(e,a){return!0}onDeActivate(){}onDestroy(){}doStepPreEvents(e){}doStepPostEvents(e){}setScale(e){this.object.setScale(e)}setScaleX(e){this.object.setScaleX(e)}setScaleY(e){this.object.setScaleY(e)}getScale(){return this.object.getScale()}getScaleY(){return this.object.getScaleY()}getScaleX(){return this.object.getScaleX()}}t.ScalableBehavior=o,t.registerBehavior("ScalableCapability::ScalableBehavior",t.ScalableBehavior)})(gdjs||(gdjs={})); +//# sourceMappingURL=ScalableBehavior.js.map diff --git a/object-capabilities/TextContainerBehavior.js b/object-capabilities/TextContainerBehavior.js new file mode 100644 index 0000000000000000000000000000000000000000..127373e430511ccc8c982d6469170a1179a0aeb1 --- /dev/null +++ b/object-capabilities/TextContainerBehavior.js @@ -0,0 +1,2 @@ +var gdjs;(function(t){class a extends t.RuntimeBehavior{constructor(e,n,i){super(e,n,i);this.object=i}usesLifecycleFunction(){return!1}updateFromBehaviorData(e,n){return!0}onDeActivate(){}onDestroy(){}doStepPreEvents(e){}doStepPostEvents(e){}getText(){return this.object.getText()}setText(e){this.object.setText(e)}}t.TextContainerBehavior=a,t.registerBehavior("TextContainerCapability::TextContainerBehavior",t.TextContainerBehavior)})(gdjs||(gdjs={})); +//# sourceMappingURL=TextContainerBehavior.js.map diff --git a/oncetriggers.js b/oncetriggers.js new file mode 100644 index 0000000000000000000000000000000000000000..d8dab5bd8b59e521f8c868c73fe4a35909e1d98f --- /dev/null +++ b/oncetriggers.js @@ -0,0 +1,2 @@ +var gdjs;(function(i){class r{constructor(){this._onceTriggers={};this._lastFrameOnceTrigger={}}startNewFrame(){for(const e in this._lastFrameOnceTrigger)this._lastFrameOnceTrigger.hasOwnProperty(e)&&delete this._lastFrameOnceTrigger[e];for(const e in this._onceTriggers)this._onceTriggers.hasOwnProperty(e)&&(this._lastFrameOnceTrigger[e]=this._onceTriggers[e],delete this._onceTriggers[e])}triggerOnce(e){return this._onceTriggers[e]=!0,!this._lastFrameOnceTrigger.hasOwnProperty(e)}}i.OnceTriggers=r})(gdjs||(gdjs={})); +//# sourceMappingURL=oncetriggers.js.map diff --git a/pixi-renderers/CustomRuntimeObject2DPixiRenderer.js b/pixi-renderers/CustomRuntimeObject2DPixiRenderer.js new file mode 100644 index 0000000000000000000000000000000000000000..fe271d96830d22df4dbfb516dcbae576f97bae11 --- /dev/null +++ b/pixi-renderers/CustomRuntimeObject2DPixiRenderer.js @@ -0,0 +1,2 @@ +var gdjs;(function(r){class a{constructor(e,t,i){this._isContainerDirty=!0;this._debugDraw=null;this._debugDrawContainer=null;this._object=e,this._instanceContainer=t,this._pixiContainer=new PIXI.Container,this._debugDrawRenderedObjectsPoints={},this._pixiContainer.sortableChildren=!0,this._debugDraw=null;const n=i.getLayer("");n&&n.getRenderer().addRendererObject(this._pixiContainer,e.getZOrder())}reinitialize(e,t){this._object=e,this._isContainerDirty=!0;const i=t.getLayer("");i&&i.getRenderer().addRendererObject(this._pixiContainer,e.getZOrder())}getRendererObject(){return this._pixiContainer}get3DRendererObject(){return null}_updatePIXIContainer(){const e=this._object.getScaleX(),t=this._object.getScaleY(),i=this._object.getOpacity();this._pixiContainer.pivot.x=this._object.getUnscaledCenterX(),this._pixiContainer.pivot.y=this._object.getUnscaledCenterY(),this._pixiContainer.position.x=this._object.getX()+this._pixiContainer.pivot.x*Math.abs(e),this._pixiContainer.position.y=this._object.getY()+this._pixiContainer.pivot.y*Math.abs(t),this._pixiContainer.rotation=r.toRad(this._object.angle),this._pixiContainer.scale.x=e*(this._object.isFlippedX()?-1:1),this._pixiContainer.scale.y=t*(this._object.isFlippedY()?-1:1),this._pixiContainer.visible=!this._object.hidden,this._pixiContainer.alpha=i/255,this._isContainerDirty=!1}ensureUpToDate(){this._isContainerDirty&&this._updatePIXIContainer()}update(){this._isContainerDirty=!0}updateX(){const e=this._object.getScaleX();this._pixiContainer.position.x=this._object.x+this._pixiContainer.pivot.x*Math.abs(e)}updateY(){const e=this._object.getScaleY();this._pixiContainer.position.y=this._object.y+this._pixiContainer.pivot.y*Math.abs(e)}updateAngle(){this._pixiContainer.rotation=r.toRad(this._object.angle)}updateOpacity(){const e=this._object.getOpacity();this._pixiContainer.alpha=e/255}updateVisibility(){this._pixiContainer.visible=!this._object.hidden}getPIXIContainer(){return this._pixiContainer}getPIXIRenderer(){return null}setLayerIndex(e,t){const i=e.getRenderer();let n=i.getRendererObject();e.isLightingLayer()&&(n=i.getLightingSprite()),!!n&&this._pixiContainer.children.indexOf(n)!==t&&(this._pixiContainer.removeChild(n),this._pixiContainer.addChildAt(n,t))}static getAnimationFrameTextureManager(e){return r.SpriteRuntimeObjectPixiRenderer.getAnimationFrameTextureManager(e)}}r.CustomRuntimeObject2DPixiRenderer=a,r.CustomRuntimeObject2DRenderer=r.CustomRuntimeObject2DPixiRenderer})(gdjs||(gdjs={})); +//# sourceMappingURL=CustomRuntimeObject2DPixiRenderer.js.map diff --git a/pixi-renderers/DebuggerPixiRenderer.js b/pixi-renderers/DebuggerPixiRenderer.js new file mode 100644 index 0000000000000000000000000000000000000000..9189a2e40968930021aad0fe773c35094fb8eddf --- /dev/null +++ b/pixi-renderers/DebuggerPixiRenderer.js @@ -0,0 +1,2 @@ +var gdjs;(function(g){class R{constructor(d){this._debugDraw=null;this._debugDrawContainer=null;this._instanceContainer=d,this._debugDrawRenderedObjectsPoints={},this._debugDraw=null}getRendererObject(){return this._debugDrawContainer}renderDebugDraw(d,h,P,_){const p=this._instanceContainer.getRenderer().getRendererObject();(!this._debugDraw||!this._debugDrawContainer)&&(this._debugDrawContainer=new PIXI.Container,this._debugDraw=new PIXI.Graphics,this._debugDrawContainer.addChild(this._debugDraw),p&&p.addChild(this._debugDrawContainer));const t=this._debugDraw;for(let r in this._debugDrawRenderedObjectsPoints)this._debugDrawRenderedObjectsPoints[r].wasRendered=!1;const u=(r,e,n,c,i)=>{t.line.color=n,t.fill.color=n,t.drawCircle(c,i,3),P&&(r[e]||(r[e]=new PIXI.Text(e,{fill:n,fontSize:12}),this._debugDrawContainer.addChild(r[e])),r[e].position.set(c,i))};t.clear(),t.beginFill(),t.alpha=.8,t.lineStyle(2,255,1);const l=[0,0];for(let r=0;r{s=n.applyLayerTransformation(s[0],s[1],0,l),b.push(s[0]),b.push(s[1])}),t.fill.alpha=0,t.line.alpha=.5,t.line.color=16711680,t.drawPolygon(b)}t.fill.alpha=.3;const D=n.applyLayerTransformation(e.getCenterXInScene(),e.getCenterYInScene(),0,l);u(o.points,"Center",16776960,D[0],D[1]);const f=n.applyLayerTransformation(e.getX(),e.getY(),0,l);if(u(o.points,"Position",16711680,f[0],f[1]),e instanceof g.SpriteRuntimeObject){let a=e.getPointPosition("origin");(Math.abs(a[0]-f[0])>=1||Math.abs(a[1]-f[1])>=1)&&(a=n.applyLayerTransformation(a[0],a[1],0,l),u(o.points,"Origin",16711680,a[0],a[1]))}if(_&&e instanceof g.SpriteRuntimeObject){const a=e._animator.getCurrentFrame();if(!a)continue;for(const b in a.points.items){let s=e.getPointPosition(b);s=n.applyLayerTransformation(s[0],s[1],0,l),u(o.points,b,255,s[0],s[1])}}}for(const r in this._debugDrawRenderedObjectsPoints){const e=this._debugDrawRenderedObjectsPoints[r];if(e.wasRendered)continue;const n=e.points;for(const c in n)this._debugDrawContainer.removeChild(n[c])}t.endFill()}clearDebugDraw(){if(this._debugDraw&&this._debugDraw.clear(),this._debugDrawContainer){this._debugDrawContainer.destroy({children:!0});const d=this._instanceContainer.getRenderer().getRendererObject();d&&d.removeChild(this._debugDrawContainer)}this._debugDraw=null,this._debugDrawContainer=null,this._debugDrawRenderedObjectsPoints={}}}g.DebuggerPixiRenderer=R,g.DebuggerRenderer=g.DebuggerPixiRenderer})(gdjs||(gdjs={})); +//# sourceMappingURL=DebuggerPixiRenderer.js.map diff --git a/pixi-renderers/layer-pixi-renderer.js b/pixi-renderers/layer-pixi-renderer.js new file mode 100644 index 0000000000000000000000000000000000000000..df5a126070d36ebacbd6e4a9701991a52ddd40aa --- /dev/null +++ b/pixi-renderers/layer-pixi-renderer.js @@ -0,0 +1,15 @@ +var gdjs;(function(h){const p=new h.Logger("LayerPixiRenderer"),l=class{constructor(e,t,r){this._lightingSprite=null;this._renderTexture=null;this._oldWidth=null;this._oldHeight=null;this._threeGroup=null;this._threeScene=null;this._threeCamera=null;this._threeCameraDirty=!1;this._threeEffectComposer=null;this._threePlaneTexture=null;this._threePlaneGeometry=null;this._threePlaneMaterial=null;this._threePlaneMesh=null;this._pixiContainer=new PIXI.Container,this._pixiContainer.sortableChildren=!0,this._layer=e,this._isLightingLayer=e.isLightingLayer();const s=t.getRendererObject();s&&s.addChild(this._pixiContainer),this._pixiContainer.filters=[];const a=r.getPIXIRenderer();this._isLightingLayer?(this._clearColor=e.getClearColor(),this._setupLightingRendering(a,t)):(this._clearColor=[...h.hexNumberToRGBArray(this._layer.getRuntimeScene().getBackgroundColor()),0],this._setup3DRendering(a,t))}onCreated(){this._update3DCameraAspectAndPosition()}onGameResolutionResized(){this._update3DCameraAspectAndPosition()}_update3DCameraAspectAndPosition(){if(!!this._threeCamera){if(this._threeCamera instanceof THREE.OrthographicCamera){const e=this._layer.getWidth(),t=this._layer.getHeight();this._threeCamera.left=-e/2,this._threeCamera.right=e/2,this._threeCamera.top=t/2,this._threeCamera.bottom=-t/2}else this._threeCamera.aspect=this._layer.getWidth()/this._layer.getHeight();this._threeCamera.updateProjectionMatrix(),this.updatePosition()}}getRendererObject(){return this._pixiContainer}getThreeScene(){return this._threeScene}getThreeCamera(){return this._threeCamera}getThreeEffectComposer(){return this._threeEffectComposer}addPostProcessingPass(e){if(!this._threeEffectComposer)return;const t=this._layer.getRuntimeScene().getGame(),r=this._threeEffectComposer.passes.length-(t.getAntialiasingMode()==="none"?1:2);this._threeEffectComposer.insertPass(e,r)}removePostProcessingPass(e){!this._threeEffectComposer||this._threeEffectComposer.removePass(e)}hasPostProcessingPass(){if(!this._threeEffectComposer)return!1;const t=this._layer.getRuntimeScene().getGame().getAntialiasingMode()==="none"?2:3;return this._threeEffectComposer.passes.length>t}getLightingSprite(){return this._lightingSprite}_setup3DRendering(e,t){if(typeof THREE!="undefined")if(this._layer instanceof h.Layer){if(this._layer.getRenderingType()===h.RuntimeLayerRenderingType.THREE_D||this._layer.getRenderingType()===h.RuntimeLayerRenderingType.TWO_D_PLUS_THREE_D){if(this._threeScene||this._threeGroup||this._threeCamera)throw new Error("Tried to setup 3D rendering for a layer that is already set up.");if(this._threeScene=new THREE.Scene,this._threeScene.scale.y=-1,this._threeGroup=new THREE.Group,this._threeScene.add(this._threeGroup),this._layer.getCameraType()===h.RuntimeLayerCameraType.ORTHOGRAPHIC){const a=this._layer.getWidth(),n=this._layer.getHeight();this._threeCamera=new THREE.OrthographicCamera(-a/2,a/2,n/2,-n/2,this._layer.getInitialCamera3DNearPlaneDistance(),this._layer.getInitialCamera3DFarPlaneDistance())}else this._threeCamera=new THREE.PerspectiveCamera(this._layer.getInitialCamera3DFieldOfView(),1,this._layer.getInitialCamera3DNearPlaneDistance(),this._layer.getInitialCamera3DFarPlaneDistance());this._threeCamera.rotation.order="ZYX";const r=this._layer.getRuntimeScene().getGame(),s=r.getRenderer().getThreeRenderer();if(s&&(this._threeEffectComposer=new THREE_ADDONS.EffectComposer(s),this._threeEffectComposer.addPass(new THREE_ADDONS.RenderPass(this._threeScene,this._threeCamera)),r.getAntialiasingMode()!=="none"&&this._threeEffectComposer.addPass(new THREE_ADDONS.SMAAPass(r.getGameResolutionWidth(),r.getGameResolutionHeight())),this._threeEffectComposer.addPass(new THREE_ADDONS.OutputPass)),this._layer.getRenderingType()===h.RuntimeLayerRenderingType.TWO_D_PLUS_THREE_D){if(this._renderTexture||this._threePlaneGeometry||this._threePlaneMaterial||this._threePlaneTexture||this._threePlaneMesh)throw new Error("Tried to setup PixiJS plane for 2D rendering in 3D for a layer that is already set up.");this._createPixiRenderTexture(e),this._threePlaneGeometry=new THREE.PlaneGeometry(1,1);const a=1,n=1,u=a*n,g=new Uint8Array(4*u),_=new THREE.DataTexture(g,a,n);_.needsUpdate=!0,this._threePlaneTexture=_,this._threePlaneTexture.generateMipmaps=!1;const d=this._layer.getRuntimeScene().getGame().getScaleMode()==="nearest"?THREE.NearestFilter:THREE.LinearFilter;this._threePlaneTexture.minFilter=d,this._threePlaneTexture.magFilter=d,this._threePlaneTexture.wrapS=THREE.ClampToEdgeWrapping,this._threePlaneTexture.wrapT=THREE.ClampToEdgeWrapping;const i={vertexShader:` + varying vec2 vUv; + void main() { + vUv = uv; + gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); + } + `,fragmentShader:` + uniform sampler2D map; + varying vec2 vUv; + void main() { + vec4 texel = texture2D(map, vUv); + gl_FragColor = texel; + } + `,uniforms:{map:{value:this._threePlaneTexture}},side:THREE.FrontSide,transparent:!0};this._threePlaneMaterial=new THREE.ShaderMaterial(i),this._threePlaneMaterial,this._threePlaneMesh=new THREE.Mesh(this._threePlaneGeometry,this._threePlaneMaterial),this._threePlaneMesh.renderOrder=Number.MAX_SAFE_INTEGER,this._threeScene.add(this._threePlaneMesh)}}}else{const r=t.get3DRendererObject();if(!r)return;this._threeGroup||(this._threeGroup=new THREE.Group,r.add(this._threeGroup))}}setThreeCameraDirty(e){this._threeCameraDirty=e}show2DRenderingPlane(e){!this._threePlaneMesh||this._threePlaneMesh.visible!==e&&(this._threePlaneMesh.visible=e)}updatePosition(){const e=-h.toRad(this._layer.getCameraRotation()),t=this._layer.getCameraZoom();this._pixiContainer.rotation=e,this._pixiContainer.scale.x=t,this._pixiContainer.scale.y=t;const r=Math.cos(e),s=Math.sin(e),a=this._layer.getCameraX()*t*r-this._layer.getCameraY()*t*s,n=this._layer.getCameraX()*t*s+this._layer.getCameraY()*t*r;this._pixiContainer.position.x=this._layer.getWidth()/2-a,this._pixiContainer.position.y=this._layer.getHeight()/2-n,this._layer.getRuntimeScene().getGame().getPixelsRounding()&&(r===0||s===0)&&Number.isInteger(t)&&(this._layer.getRuntimeScene().getGame().getRenderer().getPIXIRenderer()instanceof PIXI.Renderer?(this._pixiContainer.position.x=Math.round(this._pixiContainer.position.x),this._pixiContainer.position.y=Math.round(this._pixiContainer.position.y)):(this._pixiContainer.position.x=Math.ceil(this._pixiContainer.position.x),this._pixiContainer.position.y=Math.ceil(this._pixiContainer.position.y))),this._threeCamera&&(this._threeCamera.position.x=this._layer.getCameraX(),this._threeCamera.position.y=-this._layer.getCameraY(),this._threeCamera.rotation.z=e,this._threeCamera instanceof THREE.OrthographicCamera?(this._threeCamera.zoom=this._layer.getCameraZoom(),this._threeCamera.updateProjectionMatrix(),this._threeCamera.position.z=this._layer.getCameraZ(null)):this._threeCamera.position.z=this._layer.getCameraZ(this._threeCamera.fov),this._threePlaneMesh&&(this._threePlaneMesh.scale.x=this._layer.getWidth()/t,this._threePlaneMesh.scale.y=this._layer.getHeight()/t,this._threePlaneMesh.position.x=this._threeCamera.position.x,this._threePlaneMesh.position.y=-this._threeCamera.position.y,this._threePlaneMesh.rotation.z=-e))}updateResolution(){if(this._threeEffectComposer){const e=this._layer.getRuntimeScene().getGame();this._threeEffectComposer.setSize(e.getGameResolutionWidth(),e.getGameResolutionHeight())}}isCameraRotatedIn3D(){return this._threeCamera&&(this._threeCamera.rotation.x!==0||this._threeCamera.rotation.y!==0)}transformTo3DWorld(e,t,r,s,a){const n=this._threeCamera;if(!n)return a[0]=0,a[1]=0,a;const u=this._layer.getWidth(),g=this._layer.getHeight(),_=e/u*2-1,d=-(t/g)*2+1;let i=l.vectorForProjections;if(i||(i=new THREE.Vector3,l.vectorForProjections=i),n.updateMatrixWorld(),n instanceof THREE.OrthographicCamera){i.set(_,d,0),i.unproject(n);const o=new THREE.Vector3;n.getWorldDirection(o);const m=(r-i.z)/o.z;i.x+=m*o.x,i.y+=m*o.y}else{i.set(_,d,.5),i.unproject(n),i.sub(n.position).normalize();const o=(r-n.position.z)/i.z;i.x=o*i.x+n.position.x,i.y=o*i.y+n.position.y}return!Number.isFinite(i.x)||!Number.isFinite(i.y)?(a[0]=0,a[1]=0,a):(a[0]=i.x,a[1]=-i.y,a)}updateVisibility(e){this._pixiContainer.visible=!!e,this._threeGroup&&(this._threeGroup.visible=!!e)}updatePreRender(){if(this._threeCameraDirty){const e=this.getThreeCamera();e&&e.updateProjectionMatrix(),this._threeCameraDirty=!1}}addRendererObject(e,t){const r=e;r.zIndex=t||l.zeroZOrderForPixi,this._pixiContainer.addChild(r)}changeRendererObjectZOrder(e,t){const r=e;r.zIndex=t}removeRendererObject(e){this._pixiContainer.removeChild(e)}has3DObjects(){return!!this._threeGroup&&this._threeGroup.children.length>0}has2DObjects(){return this._pixiContainer.children.length>0}add3DRendererObject(e){!this._threeGroup||this._threeGroup.add(e)}remove3DRendererObject(e){!this._threeGroup||this._threeGroup.remove(e)}updateClearColor(){this._clearColor=this._layer.getClearColor()}_createPixiRenderTexture(e){if(!e||e.type!==PIXI.RENDERER_TYPE.WEBGL)return;if(this._renderTexture){p.error("Tried to create a PixiJS RenderTexture for a layer that already has one.");return}this._oldWidth=e.screen.width,this._oldHeight=e.screen.height;const t=this._oldWidth,r=this._oldHeight,s=e.resolution;this._renderTexture=PIXI.RenderTexture.create({width:t||100,height:r||100,resolution:s}),this._renderTexture.baseTexture.scaleMode=PIXI.SCALE_MODES.LINEAR,p.info(`RenderTexture created for layer ${this._layer.getName()}.`)}renderOnPixiRenderTexture(e){if(!this._renderTexture)return;(this._oldWidth!==e.screen.width||this._oldHeight!==e.screen.height)&&(this._renderTexture.resize(e.screen.width||100,e.screen.height||100),this._oldWidth=e.screen.width,this._oldHeight=e.screen.height);const t=e.renderTexture.current||void 0,r=e.renderTexture.sourceFrame;e.renderTexture.bind(this._renderTexture),this._clearColor[3]=this._isLightingLayer?1:0,e.renderTexture.clear(this._clearColor),e.render(this._pixiContainer,{renderTexture:this._renderTexture,clear:!1}),e.renderTexture.bind(t,r,void 0)}updateThreePlaneTextureFromPixiRenderTexture(e,t){if(!this._threePlaneTexture||!this._renderTexture)return;const r=this._renderTexture.baseTexture._glTextures[t.CONTEXT_UID];if(r){const s=e.properties.get(this._threePlaneTexture);s.__webglTexture=r.texture}}_setupLightingRendering(e,t){if(this._createPixiRenderTexture(e),!this._renderTexture)return;this._lightingSprite=new PIXI.Sprite(this._renderTexture),this._lightingSprite.blendMode=PIXI.BLEND_MODES.MULTIPLY;const r=t.getRendererObject();if(r){const s=r.getChildIndex(this._pixiContainer);r.addChildAt(this._lightingSprite,s),r.removeChild(this._pixiContainer)}}};let c=l;c.zeroZOrderForPixi=Math.pow(2,-24),c.vectorForProjections=null,h.LayerPixiRenderer=c,h.LayerRenderer=h.LayerPixiRenderer})(gdjs||(gdjs={})); +//# sourceMappingURL=layer-pixi-renderer.js.map diff --git a/pixi-renderers/loadingscreen-pixi-renderer.js b/pixi-renderers/loadingscreen-pixi-renderer.js new file mode 100644 index 0000000000000000000000000000000000000000..5b34269a46c59127ea4c99ef2acc6bce94f78ca9 --- /dev/null +++ b/pixi-renderers/loadingscreen-pixi-renderer.js @@ -0,0 +1,2 @@ +var gdjs;(function(p){let a;(function(r){r[r.NOT_STARTED=0]="NOT_STARTED",r[r.STARTED=1]="STARTED",r[r.FINISHED=2]="FINISHED"})(a||(a={}));const d=(n,e,i)=>{!n||(e>0?(n.alpha+=1/e*i/1e3,n.alpha>1&&(n.alpha=1)):n.alpha=1)},_=n=>!n||n.alpha>=1;class c{constructor(e,i,r,t,s){this._backgroundSprite=null;this._gdevelopLogoSprite=null;this._progressBarGraphics=null;this._state=0;this._startTimeInMs=0;this._backgroundReadyTimeInMs=0;this._lastFrameTimeInMs=0;this._progressPercent=0;if(this._loadingScreenData=r,this._isWatermarkEnabled=t,this._isFirstLayout=s,this._loadingScreenContainer=new PIXI.Container,this._pixiRenderer=e.getPIXIRenderer(),!this._pixiRenderer)return;const o=i.getOrLoadPIXITexture(r.backgroundImageResourceName);o!==i.getInvalidPIXITexture()&&(this._backgroundSprite=PIXI.Sprite.from(o),this._backgroundSprite.alpha=0,this._backgroundSprite.anchor.x=.5,this._backgroundSprite.anchor.y=.5,this._loadingScreenContainer.addChild(this._backgroundSprite)),r.showGDevelopSplash&&s&&(this._gdevelopLogoSprite=PIXI.Sprite.from(p.gdevelopLogo),this._gdevelopLogoSprite.alpha=0,this._gdevelopLogoSprite.anchor.x=.5,this._gdevelopLogoSprite.anchor.y=.5,this._loadingScreenContainer.addChild(this._gdevelopLogoSprite)),r.showProgressBar&&(this._progressBarGraphics=new PIXI.Graphics,this._progressBarGraphics.alpha=0,this._loadingScreenContainer.addChild(this._progressBarGraphics)),this._render(performance.now())}setPercent(e){this._progressPercent=e}_startLoadingScreen(){!this._pixiRenderer||(this._state=1,this._startTimeInMs=performance.now())}_updatePositions(){if(!!this._pixiRenderer){if(this._backgroundSprite&&this._backgroundSprite.texture.valid){this._backgroundSprite.position.x=this._pixiRenderer.width/2,this._backgroundSprite.position.y=this._pixiRenderer.height/2;const e=Math.max(this._pixiRenderer.width/this._backgroundSprite.texture.width,this._pixiRenderer.height/this._backgroundSprite.texture.height);this._backgroundSprite.scale.x=e,this._backgroundSprite.scale.y=e}if(this._gdevelopLogoSprite){this._gdevelopLogoSprite.position.x=this._pixiRenderer.width/2,this._gdevelopLogoSprite.position.y=this._pixiRenderer.height/2;const e=680,i=this._pixiRenderer.width>this._pixiRenderer.height&&this._pixiRenderer.width>500?150:35,t=Math.min(e,Math.max(1,this._pixiRenderer.width-i*2))/e;this._gdevelopLogoSprite.scale.x=t,this._gdevelopLogoSprite.scale.y=t,this._gdevelopLogoSprite.visible=this._pixiRenderer.width>200&&this._pixiRenderer.height>200}}}_render(e){!this._pixiRenderer||this._state!==2&&(requestAnimationFrame(()=>this._render(performance.now())),this._renderIfNeeded(e))}renderIfNeeded(){return this._renderIfNeeded(performance.now())}_renderIfNeeded(e){if(e-this._lastFrameTimeInMs<1e3/60||!this._pixiRenderer)return!1;const i=this._lastFrameTimeInMs?e-this._lastFrameTimeInMs:0;if(this._lastFrameTimeInMs=e,this._updatePositions(),this._state===2)return!0;if(this._state==0)return this._pixiRenderer.background.color=this._loadingScreenData.backgroundColor,(!this._backgroundSprite||this._backgroundSprite.texture.valid)&&this._startLoadingScreen(),!0;const r=this._loadingScreenData.backgroundFadeInDuration;if(this._backgroundSprite||d(this._pixiRenderer.background,r,i),this._pixiRenderer.clear(),d(this._backgroundSprite,r,i),_(this._backgroundSprite)){this._backgroundReadyTimeInMs||(this._backgroundReadyTimeInMs=e);const t=this._loadingScreenData.logoAndProgressFadeInDuration,s=this._loadingScreenData.logoAndProgressLogoFadeInDelay;e-this._backgroundReadyTimeInMs>s*1e3&&(d(this._gdevelopLogoSprite,t,i),d(this._progressBarGraphics,t,i))}if(this._progressBarGraphics){const t=this._loadingScreenData.progressBarColor;let s=this._loadingScreenData.progressBarWidthPercent/100*this._pixiRenderer.width;this._loadingScreenData.progressBarMaxWidth>0&&s>this._loadingScreenData.progressBarMaxWidth&&(s=this._loadingScreenData.progressBarMaxWidth),this._loadingScreenData.progressBarMinWidth>0&&sthis._loadingScreenData.minDuration)return this._state=2,Promise.resolve();const r=this._loadingScreenData.minDuration-e;return this.setPercent(100),new Promise(t=>setTimeout(()=>{this._state=2,t()},r*1e3))}}p.LoadingScreenRenderer=c})(gdjs||(gdjs={})); +//# sourceMappingURL=loadingscreen-pixi-renderer.js.map diff --git a/pixi-renderers/pixi-bitmapfont-manager.js b/pixi-renderers/pixi-bitmapfont-manager.js new file mode 100644 index 0000000000000000000000000000000000000000..22d8d40620edc9cf9b1ec9b25b442b92a08bae83 --- /dev/null +++ b/pixi-renderers/pixi-bitmapfont-manager.js @@ -0,0 +1,2 @@ +var gdjs;(function(a){const n=new a.Logger("Bitmap text"),l="GDJS-DEFAULT-BITMAP-FONT",m=5,p=(s,t)=>{const i=s.font;return s.font=t,PIXI.BitmapFont.available[t]=s,delete PIXI.BitmapFont.available[i],PIXI.BitmapFont.available[t]},d=["bitmapFont"];class u{constructor(t,i){this._pixiBitmapFontsInUse={};this._pixiBitmapFontsToUninstall=[];this._loadedFontsData=new a.ResourceCache;this._defaultSlugFontName=null;this._imageManager=i,this._resourceLoader=t}getResourceKinds(){return d}getDefaultBitmapFont(){if(this._defaultSlugFontName!==null)return PIXI.BitmapFont.available[this._defaultSlugFontName];const t="Arial",i=new PIXI.TextStyle({fontFamily:t,fontSize:20,padding:5,align:"left",fill:"#ffffff",wordWrap:!0,lineHeight:20}),e=p(PIXI.BitmapFont.from(t,i,{chars:[[" ","~"]]}),l);return this._defaultSlugFontName=e.font,e}_markBitmapFontAsUsed(t){this._pixiBitmapFontsInUse[t]=this._pixiBitmapFontsInUse[t]||{objectsUsingTheFont:0},this._pixiBitmapFontsInUse[t].objectsUsingTheFont++;for(let i=0;im)){const i=this._pixiBitmapFontsToUninstall.shift();PIXI.BitmapFont.uninstall(i),n.log("Bitmap Text",'Uninstalled BitmapFont "'+i+'" from memory.')}}}obtainBitmapFont(t,i){const e=t+"@"+i;if(PIXI.BitmapFont.available[e])return this._markBitmapFontAsUsed(e),PIXI.BitmapFont.available[e];const o=this._loadedFontsData.getFromName(t);if(!o)return n.warn('Could not find Bitmap Font for resource named "'+t+'". The default font will be used.'),this.getDefaultBitmapFont();const c=this._imageManager.getPIXITexture(i);try{const r=p(PIXI.BitmapFont.install(o,c),e);return this._markBitmapFontAsUsed(e),r}catch(r){return n.error('Could not load the Bitmap Font for resource named "'+t+'". The default font will be used. Error is: '+r),this.getDefaultBitmapFont()}}async processResource(t){}async loadResource(t){const i=this._resourceLoader.getResource(t);if(!i){n.warn('Unable to find bitmap font for resource "'+t+'".');return}if(!this._loadedFontsData.get(i))try{const o=await(await fetch(this._resourceLoader.getFullUrl(i.file),{credentials:this._resourceLoader.checkIfCredentialsRequired(i.file)?"include":"same-origin"})).text();this._loadedFontsData.set(i,o)}catch(e){n.error("Can't fetch the bitmap font file "+i.file+", error: "+e)}}dispose(){for(const t in this._pixiBitmapFontsInUse)PIXI.BitmapFont.uninstall(t);for(const t of this._pixiBitmapFontsToUninstall)PIXI.BitmapFont.uninstall(t);this._pixiBitmapFontsInUse={},this._pixiBitmapFontsToUninstall.length=0,this._loadedFontsData.clear()}}a.PixiBitmapFontManager=u,a.BitmapFontManager=a.PixiBitmapFontManager})(gdjs||(gdjs={})); +//# sourceMappingURL=pixi-bitmapfont-manager.js.map diff --git a/pixi-renderers/pixi-effects-manager.js b/pixi-renderers/pixi-effects-manager.js new file mode 100644 index 0000000000000000000000000000000000000000..bc29af19d014c0c4275d700221b334c33b16e952 --- /dev/null +++ b/pixi-renderers/pixi-effects-manager.js @@ -0,0 +1,2 @@ +var gdjs;(function(i){class f{initializeEffect(e,t,n){const r=i.PixiFiltersTools.getFilterCreator(e.effectType);return r?(t[e.name]=r.makeFilter(n,e),!0):(console.warn(`Effect: "${e.name}", on layer: "${n.getName()}", has an unknown effect type: "${e.effectType}". Was it registered properly? Is the effect type correct?`),!1)}updatePreRender(e,t){for(const n in e)e[n].updatePreRender(t)}addEffect(e,t,n){let r=!0;return r=this.initializeEffect(e,t,n)&&r,r=this.updateAllEffectParameters(t,e)&&r,t[e.name]&&(r=t[e.name].applyEffect(n)&&r),r}removeEffect(e,t,n){const r=e[n];return r?(r.removeEffect(t),delete e[n],!0):!1}clearEffects(e){return e&&(e.filters=[]),!0}setEffectDoubleParameter(e,t,n,r){const a=e[t];return a?(a.updateDoubleParameter(n,r),!0):!1}setEffectStringParameter(e,t,n,r){const a=e[t];return a?(a.updateStringParameter(n,r),!0):!1}setEffectBooleanParameter(e,t,n,r){const a=e[t];return a?(a.updateBooleanParameter(n,r),!0):!1}updateAllEffectParameters(e,t){let n=!0,r=!0,a=!0;for(let s in t.doubleParameters)n=this.setEffectDoubleParameter(e,t.name,s,t.doubleParameters[s])&&n;for(let s in t.stringParameters)r=this.setEffectStringParameter(e,t.name,s,t.stringParameters[s])&&r;for(let s in t.booleanParameters)a=this.setEffectBooleanParameter(e,t.name,s,t.booleanParameters[s])&&a;return n&&r&&a}hasEffect(e,t){return!!e[t]}enableEffect(e,t,n,r){const a=e[n];!a||a.setEnabled(t,r)}isEffectEnabled(e,t,n){const r=e[n];return r?r.isEnabled(t):!1}}i.EffectsManager=f})(gdjs||(gdjs={})); +//# sourceMappingURL=pixi-effects-manager.js.map diff --git a/pixi-renderers/pixi-filters-tools.js b/pixi-renderers/pixi-filters-tools.js new file mode 100644 index 0000000000000000000000000000000000000000..fa3be126c7e08a097352415b47934dedc81bdf5a --- /dev/null +++ b/pixi-renderers/pixi-filters-tools.js @@ -0,0 +1,2 @@ +var gdjs;(function(o){const f=new o.Logger("Filters");let m;(function(n){n.clampValue=function(r,e,t){return Math.max(e,Math.min(t,r))},n.clampKernelSize=function(r,e,t){const a=Math.round((t-e)/2+1),s=new Array(a);for(let l=0;la!==this.pixiFilter),!0):!1}updatePreRender(e){this.filterCreator.updatePreRender(this.pixiFilter,e)}updateDoubleParameter(e,t){this.filterCreator.updateDoubleParameter(this.pixiFilter,e,t)}updateStringParameter(e,t){this.filterCreator.updateStringParameter(this.pixiFilter,e,t)}updateBooleanParameter(e,t){this.filterCreator.updateBooleanParameter(this.pixiFilter,e,t)}updateColorParameter(e,t){this.filterCreator.updateColorParameter(this.pixiFilter,e,t)}getDoubleParameter(e){return this.filterCreator.getDoubleParameter(this.pixiFilter,e)}getColorParameter(e){return this.filterCreator.getColorParameter(this.pixiFilter,e)}getNetworkSyncData(){return{ena:this.pixiFilter.enabled,fc:this.filterCreator.getNetworkSyncData(this.pixiFilter)}}updateFromNetworkSyncData(e){this.pixiFilter.enabled=e.ena,this.filterCreator.updateFromNetworkSyncData(this.pixiFilter,e.fc)}}n.PixiFilter=u;class F{isEnabled(e){return!1}setEnabled(e,t){return!1}applyEffect(e){return!1}removeEffect(e){return!1}updatePreRender(e){}updateDoubleParameter(e,t){}updateStringParameter(e,t){}updateBooleanParameter(e,t){}updateColorParameter(e,t){}getDoubleParameter(e){return 0}getColorParameter(e){return 0}getNetworkSyncData(){return{}}updateFromNetworkSyncData(e){}}n.EmptyFilter=F})(m=o.PixiFiltersTools||(o.PixiFiltersTools={}))})(gdjs||(gdjs={})); +//# sourceMappingURL=pixi-filters-tools.js.map diff --git a/pixi-renderers/pixi-image-manager.js b/pixi-renderers/pixi-image-manager.js new file mode 100644 index 0000000000000000000000000000000000000000..7e108e6fd089dff1855acebacb776369ad9ff6c6 --- /dev/null +++ b/pixi-renderers/pixi-image-manager.js @@ -0,0 +1,2 @@ +var gdjs;(function(l){const a=new l.Logger("PIXI Image manager"),T=(n,e)=>{a.error("Unable to load file "+n+" with error:",e||"(unknown error)")},d=(n,e)=>{!n||e.smoothed||(n.baseTexture.scaleMode=PIXI.SCALE_MODES.NEAREST)},A=(n,e)=>{e&&!e.smoothed&&(n.magFilter=THREE.NearestFilter,n.minFilter=THREE.NearestFilter)},g=["image","video"];class x{constructor(e){this._loadedTextures=new l.ResourceCache;this._diskTextures=new Map;this._rectangleTextures=new Map;this._scaledTextures=new Map;this._getImageResource=e=>{const r=this._resourceLoader.getResource(e);return r&&this.getResourceKinds().includes(r.kind)?r:null};this._resourceLoader=e,this._invalidTexture=PIXI.Texture.from("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMAAAADACAMAAABlApw1AAAAkFBMVEWdIvr///+hOfrx6v7i0/39/P+eK/rn2v6vbPv7+f/cx/359v/38v7s4v7Wvf3LqvzFnvysY/v18P6jQvrz7P7u5P7ezP3Or/yoV/qlTfrq3v7l1v3hz/2fLvrTuPy0efufMvraxP3YwP3AlPu2fvuuavvRtPy8i/uqXfu5hvvIo/y4gvuxcvugNfq+j/vCmfxfwZ2lAAAF60lEQVR42uzPMQ0AAAjEQPBvmhkBDE+uAppcdXgfAHXY9R4AAAAAAAAAAGAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAEA/YAQAMNfa2nCoMhmE4HxhcFESggMhGtNa11NLl/d9dO53pQRMklPKn4TllhuEdEjb/CK/WWPXvBTjOOVxvDsvVO3u03e8EnC9BZnNMwNcfYDU728NkLpoDLpmPSQU6Ax5vNsfE0lpbwOs1AYGbroDnBCQyPQH7tQsanpYAqwQVftEQEKWgE9AHtAkIpTV1QBOD1Jk4IPJA6y9tQF2C2Io24ApqXq4OMHgBvTsSBjgVBnA9P7HH2xEGPOM+7hVPQdhGUZRvt4/WeHvCgBJ3uFXYsn4m/BO3HJ2Ko8XuMSogQBdvzXoYFRCjQ3GazWQuRIfKms1o0Skge3DmMxvdckiWzoyGu0dIvGhO0+kAkmBW4/UVRPw0qwAfopKpmRPwh0N0ZGrmBPyDyI2Yms6AaiH48nd3g8hmsijMFkrZ9UQSwCFY9j+EHpgor1wM4gaO9oAKog0TtDEGuxoQIF7DOcZwqQEB4kJe4Bt83QHOEiJLuAGe2QG2KuAF37HUHVAn0wZsdAfs/WkD8pkHrGrtSyhWBVgxhnti5m1itsZg/IUiIO4NKJQBzoFjoJjRB6hfZA0T/U8xTEASkMo7TfEtJLGa4CB81JYeZM3PAmQfUQUEtsUY+zx66N6I+MTuySFJPk48Sl9ACYH/1s6dICkKQwEYfg9NkE1QdhkREXGZ1rn/7aZmrR4SAdHnMpXvAF31txETSPA/BXjy9QBiV0KKAhNuCwA5E5vS1hWZtYc+XBScYbDhAVsDm7xeuxYX2GQUzwgAu9+cHrFzkuoCTcAamz7ar6O46QiQr6WNLVGAOFjjjrE88rsDIskHRxRQYVPecTlEszvAEP8tVAErbFrDJ0sHRceuAA8FCVXAB2u/81OjiOW8PUAXR9CJKsCfY4OtwSeFhRJm2haQGpJ5EFUAjLCp6vGQL9gUlwM8yUyaLmDcccXeGyjleKf+f3IOdAHiILc5CD8FMuzLZg8SmiWOIMKAr9gxhvYMLzKCsp5onbe0cUUY4KMgb6y5sN1I183Y+yM2Q3EE+VQB8mXjqIDPEhtvFJE+4Cg7t2Nv8EZn0oAdCnSh8SZWQRrALWxijS+dtqAfQcMDwETBmMM/fB1vcCYOWKGo+cup3VBgnYgDtKDHjXB/gUNl5I9Z8z7bCE9THMgjD0gZCmwfmg4BDhEW5AGwRlHGocmfWni9KdAHTIyeF780MvBKrCIIEMS9HwhtTYZXCeARAVrQfz/wrMRrlBQBohol7C3I8KQOGPZVPSbAH0kLJnBBlS+wm/PleFiSBIg22PoZiLi/yZ3AkC9zRuG69hLhoCplwHKMMtaOQwu+XR3itfnXOvcOq9VMe8aGp5mNUqUPT9crADyUcyZAgCAAdJSzvwIBgoDEQjlWJu/xWoaVgRfMa+0dAuBg4MUE178xYDuR2t8zAI4MLyfE6fAAvhsxKeN81wDIsYUVbQYGrMZ4QcTvGwBrbGWXX0/XBvDDmOEFQQp3DuARdljEiQa9cf+Y4WWb+289LiLsNB+7uz4RxS7WGbbIKfZO85phD8Y8Ko/bWcJBwt/PdlMzMLDduqDZ/L0zsDcrdJxFNI3dX+JppDuOM8c+oiXV7vXVCB8gO9Ftv/czJJdplOcHuGshLfNEfABiFyKlbEl+gqOoGZKJl484gjLLkEa4HTobfYlxxGrtgWcpzzremf7x2OO4vMoMvBsWnjkQB4gmEd5J8PU5r2nj23yEt1scORAFdCsm0znD4Zg9/eC0a+JuVa0bOARb5BXpor4/v8qdOV7DDstvKQd4kYAfllW/l+Sx+RfzW+XDDy8V8BPnyc511wvHCQPb+F3DDDsIHcfJStc9p5w//zRrL1qazH7ZJ6nP4a8XOI77IlTAld4w4FVu7qqA31SAClABKkAFqAAVoAJUgApQASpABagAFaACVIAKUAH/TcB7e/uA7+03ZsJSaNOuAAAAAElFTkSuQmCC",{width:192,height:192}),this._loadedThreeTextures=new Hashtable,this._loadedThreeMaterials=new Hashtable}getResourceKinds(){return g}getPIXITexture(e){const r=this._getImageResource(e);if(!r)return a.warn('Unable to find texture for resource "'+e+'".'),this._invalidTexture;const t=this._loadedTextures.get(r);return t?t.valid?t:(a.error("Texture for "+e+" is not valid anymore (or never was)."),this._invalidTexture):this._invalidTexture}getOrLoadPIXITexture(e){const r=this._getImageResource(e);if(!r)return a.warn('Unable to find texture for resource "'+e+'".'),this._invalidTexture;const t=this._loadedTextures.get(r);if(t)return t.valid?t:(a.error("Texture for "+e+" is not valid anymore (or never was)."),this._invalidTexture);a.log('Loading texture for resource "'+e+'"...');const i=r.file,o=this._resourceLoader.getFullUrl(i),s=PIXI.Texture.from(o,{resourceOptions:{crossorigin:this._resourceLoader.checkIfCredentialsRequired(i)?"use-credentials":"anonymous"}}).on("error",u=>{T(i,u)});if(!s)throw new Error("Texture loading by PIXI returned nothing for file "+i+" behind url "+o);return d(s,r),this._loadedTextures.set(r,s),s}getThreeTexture(e){const r=this._loadedThreeTextures.get(e);if(r)return r;const t=this.getPIXITexture(e);if(!this._resourceLoader._runtimeGame.getRenderer().getPIXIRenderer())throw new Error("No PIXI renderer was found.");const o=t.baseTexture.resource.source;if(!(o instanceof HTMLImageElement))throw new Error(`Can't load texture for resource "${e}" as it's not an image.`);const s=new THREE.Texture(o);s.magFilter=THREE.LinearFilter,s.minFilter=THREE.LinearFilter,s.wrapS=THREE.RepeatWrapping,s.wrapT=THREE.RepeatWrapping,s.colorSpace=THREE.SRGBColorSpace,s.needsUpdate=!0;const u=this._getImageResource(e);return A(s,u),this._loadedThreeTextures.put(e,s),s}getThreeMaterial(e,{useTransparentTexture:r,forceBasicMaterial:t}){const i=`${e}|${r?1:0}|${t?1:0}`,o=this._loadedThreeMaterials.get(i);if(o)return o;const s=t?new THREE.MeshBasicMaterial({map:this.getThreeTexture(e),side:r?THREE.DoubleSide:THREE.FrontSide,transparent:r}):new THREE.MeshStandardMaterial({map:this.getThreeTexture(e),side:r?THREE.DoubleSide:THREE.FrontSide,transparent:r,metalness:0});return this._loadedThreeMaterials.put(i,s),s}getPIXIVideoTexture(e){if(e==="")return this._invalidTexture;const r=this._getImageResource(e);if(!r)return a.warn('Unable to find video texture for resource "'+e+'".'),this._invalidTexture;const t=this._loadedTextures.get(r);return t||this._invalidTexture}getInvalidPIXITexture(){return this._invalidTexture}async loadResource(e){const r=this._resourceLoader.getResource(e);if(!r){a.warn('Unable to find texture for resource "'+e+'".');return}await this._loadTexture(r)}async processResource(e){}async _loadTexture(e){if(!this._loadedTextures.get(e))try{if(e.kind==="video")await new Promise((r,t)=>{const i=PIXI.Texture.from(this._resourceLoader.getFullUrl(e.file),{resourceOptions:{crossorigin:this._resourceLoader.checkIfCredentialsRequired(e.file)?"use-credentials":"anonymous",autoPlay:!1}}).on("error",s=>{t(s)});i.baseTexture.on("loaded",()=>{this._loadedTextures.set(e,i),d(i,e),r()}).on("error",s=>{t(s)})});else{const r=PIXI.Texture.from(this._resourceLoader.getFullUrl(e.file),{resourceOptions:{autoLoad:!1,crossorigin:this._resourceLoader.checkIfCredentialsRequired(e.file)?"use-credentials":"anonymous"}});await r.baseTexture.resource.load(),this._loadedTextures.set(e,r),d(r,e)}}catch(r){T(e.file,r)}}getOrCreateDiskTexture(e,r){let t=this._diskTextures.get(e);if(!t){const i=new PIXI.Graphics;i.lineStyle(0,0,0),i.beginFill(l.rgbToHexNumber(255,255,255),1),i.drawCircle(0,0,e),i.endFill(),t=r.generateTexture(i),i.destroy(),this._diskTextures.set(e,t)}return t}getOrCreateRectangleTexture(e,r,t){const i=`${e}_${r}`;let o=this._rectangleTextures.get(i);if(!o){const s=new PIXI.Graphics;s.lineStyle(0,0,0),s.beginFill(l.rgbToHexNumber(255,255,255),1),s.drawRect(0,0,e,r),s.endFill(),o=t.generateTexture(s),s.destroy(),this._rectangleTextures.set(i,o)}return o}getOrCreateScaledTexture(e,r,t,i){const o=`${e}_${r}_${t}`;let s=this._scaledTextures.get(o);if(!s){const u=new PIXI.Graphics,c=new PIXI.Sprite(this.getPIXITexture(e));c.width=r,c.height=t,u.addChild(c),s=i.generateTexture(u),u.destroy(),this._scaledTextures.set(o,s)}return s}dispose(){this._loadedTextures.clear();const e=[];this._loadedThreeTextures.values(e),this._loadedThreeTextures.clear();for(const t of e)t.dispose();const r=[];this._loadedThreeMaterials.values(r),this._loadedThreeMaterials.clear();for(const t of r)t.dispose();for(const t of this._diskTextures.values())t.destroyed||t.destroy();this._diskTextures.clear();for(const t of this._rectangleTextures.values())t.destroyed||t.destroy();this._rectangleTextures.clear();for(const t of this._scaledTextures.values())t.destroyed||t.destroy();this._scaledTextures.clear()}}l.PixiImageManager=x,l.ImageManager=l.PixiImageManager})(gdjs||(gdjs={})); +//# sourceMappingURL=pixi-image-manager.js.map diff --git a/pixi-renderers/pixi.js b/pixi-renderers/pixi.js new file mode 100644 index 0000000000000000000000000000000000000000..5f885b19830e541b827faccd7ab261f85fa99d5e --- /dev/null +++ b/pixi-renderers/pixi.js @@ -0,0 +1,1163 @@ +/*! + * pixi.js-legacy - v7.3.0 + * Compiled Mon, 18 Sep 2023 15:35:01 UTC + * + * pixi.js-legacy is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */var PIXI=function(y){"use strict";var be=(i=>(i[i.WEBGL_LEGACY=0]="WEBGL_LEGACY",i[i.WEBGL=1]="WEBGL",i[i.WEBGL2=2]="WEBGL2",i))(be||{}),li=(i=>(i[i.UNKNOWN=0]="UNKNOWN",i[i.WEBGL=1]="WEBGL",i[i.CANVAS=2]="CANVAS",i))(li||{}),ui=(i=>(i[i.COLOR=16384]="COLOR",i[i.DEPTH=256]="DEPTH",i[i.STENCIL=1024]="STENCIL",i))(ui||{}),C=(i=>(i[i.NORMAL=0]="NORMAL",i[i.ADD=1]="ADD",i[i.MULTIPLY=2]="MULTIPLY",i[i.SCREEN=3]="SCREEN",i[i.OVERLAY=4]="OVERLAY",i[i.DARKEN=5]="DARKEN",i[i.LIGHTEN=6]="LIGHTEN",i[i.COLOR_DODGE=7]="COLOR_DODGE",i[i.COLOR_BURN=8]="COLOR_BURN",i[i.HARD_LIGHT=9]="HARD_LIGHT",i[i.SOFT_LIGHT=10]="SOFT_LIGHT",i[i.DIFFERENCE=11]="DIFFERENCE",i[i.EXCLUSION=12]="EXCLUSION",i[i.HUE=13]="HUE",i[i.SATURATION=14]="SATURATION",i[i.COLOR=15]="COLOR",i[i.LUMINOSITY=16]="LUMINOSITY",i[i.NORMAL_NPM=17]="NORMAL_NPM",i[i.ADD_NPM=18]="ADD_NPM",i[i.SCREEN_NPM=19]="SCREEN_NPM",i[i.NONE=20]="NONE",i[i.SRC_OVER=0]="SRC_OVER",i[i.SRC_IN=21]="SRC_IN",i[i.SRC_OUT=22]="SRC_OUT",i[i.SRC_ATOP=23]="SRC_ATOP",i[i.DST_OVER=24]="DST_OVER",i[i.DST_IN=25]="DST_IN",i[i.DST_OUT=26]="DST_OUT",i[i.DST_ATOP=27]="DST_ATOP",i[i.ERASE=26]="ERASE",i[i.SUBTRACT=28]="SUBTRACT",i[i.XOR=29]="XOR",i))(C||{}),Ot=(i=>(i[i.POINTS=0]="POINTS",i[i.LINES=1]="LINES",i[i.LINE_LOOP=2]="LINE_LOOP",i[i.LINE_STRIP=3]="LINE_STRIP",i[i.TRIANGLES=4]="TRIANGLES",i[i.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",i[i.TRIANGLE_FAN=6]="TRIANGLE_FAN",i))(Ot||{}),M=(i=>(i[i.RGBA=6408]="RGBA",i[i.RGB=6407]="RGB",i[i.RG=33319]="RG",i[i.RED=6403]="RED",i[i.RGBA_INTEGER=36249]="RGBA_INTEGER",i[i.RGB_INTEGER=36248]="RGB_INTEGER",i[i.RG_INTEGER=33320]="RG_INTEGER",i[i.RED_INTEGER=36244]="RED_INTEGER",i[i.ALPHA=6406]="ALPHA",i[i.LUMINANCE=6409]="LUMINANCE",i[i.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",i[i.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",i[i.DEPTH_STENCIL=34041]="DEPTH_STENCIL",i))(M||{}),Me=(i=>(i[i.TEXTURE_2D=3553]="TEXTURE_2D",i[i.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",i[i.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",i[i.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",i[i.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",i[i.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",i[i.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",i[i.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",i[i.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",i))(Me||{}),$=(i=>(i[i.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",i[i.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",i[i.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",i[i.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",i[i.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",i[i.UNSIGNED_INT=5125]="UNSIGNED_INT",i[i.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",i[i.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",i[i.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",i[i.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",i[i.BYTE=5120]="BYTE",i[i.SHORT=5122]="SHORT",i[i.INT=5124]="INT",i[i.FLOAT=5126]="FLOAT",i[i.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",i[i.HALF_FLOAT=36193]="HALF_FLOAT",i))($||{}),k=(i=>(i[i.FLOAT=0]="FLOAT",i[i.INT=1]="INT",i[i.UINT=2]="UINT",i))(k||{}),Bt=(i=>(i[i.NEAREST=0]="NEAREST",i[i.LINEAR=1]="LINEAR",i))(Bt||{}),Zt=(i=>(i[i.CLAMP=33071]="CLAMP",i[i.REPEAT=10497]="REPEAT",i[i.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",i))(Zt||{}),Ht=(i=>(i[i.OFF=0]="OFF",i[i.POW2=1]="POW2",i[i.ON=2]="ON",i[i.ON_MANUAL=3]="ON_MANUAL",i))(Ht||{}),At=(i=>(i[i.NPM=0]="NPM",i[i.UNPACK=1]="UNPACK",i[i.PMA=2]="PMA",i[i.NO_PREMULTIPLIED_ALPHA=0]="NO_PREMULTIPLIED_ALPHA",i[i.PREMULTIPLY_ON_UPLOAD=1]="PREMULTIPLY_ON_UPLOAD",i[i.PREMULTIPLIED_ALPHA=2]="PREMULTIPLIED_ALPHA",i))(At||{}),Vt=(i=>(i[i.NO=0]="NO",i[i.YES=1]="YES",i[i.AUTO=2]="AUTO",i[i.BLEND=0]="BLEND",i[i.CLEAR=1]="CLEAR",i[i.BLIT=2]="BLIT",i))(Vt||{}),ci=(i=>(i[i.AUTO=0]="AUTO",i[i.MANUAL=1]="MANUAL",i))(ci||{}),Rt=(i=>(i.LOW="lowp",i.MEDIUM="mediump",i.HIGH="highp",i))(Rt||{}),pt=(i=>(i[i.NONE=0]="NONE",i[i.SCISSOR=1]="SCISSOR",i[i.STENCIL=2]="STENCIL",i[i.SPRITE=3]="SPRITE",i[i.COLOR=4]="COLOR",i))(pt||{}),Pa=(i=>(i[i.RED=1]="RED",i[i.GREEN=2]="GREEN",i[i.BLUE=4]="BLUE",i[i.ALPHA=8]="ALPHA",i))(Pa||{}),ft=(i=>(i[i.NONE=0]="NONE",i[i.LOW=2]="LOW",i[i.MEDIUM=4]="MEDIUM",i[i.HIGH=8]="HIGH",i))(ft||{}),jt=(i=>(i[i.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",i[i.ARRAY_BUFFER=34962]="ARRAY_BUFFER",i[i.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",i))(jt||{});const Ma={createCanvas:(i,t)=>{const e=document.createElement("canvas");return e.width=i,e.height=t,e},getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>{var i;return(i=document.baseURI)!=null?i:window.location.href},getFontFaceSet:()=>document.fonts,fetch:(i,t)=>fetch(i,t),parseXML:i=>new DOMParser().parseFromString(i,"text/xml")},N={ADAPTER:Ma,RESOLUTION:1,CREATE_IMAGE_BITMAP:!1,ROUND_PIXELS:!1};var Ar=/iPhone/i,Da=/iPod/i,Oa=/iPad/i,Ba=/\biOS-universal(?:.+)Mac\b/i,wr=/\bAndroid(?:.+)Mobile\b/i,Fa=/Android/i,ze=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,di=/Silk/i,he=/Windows Phone/i,Na=/\bWindows(?:.+)ARM\b/i,La=/BlackBerry/i,Ua=/BB10/i,ka=/Opera Mini/i,Ga=/\b(CriOS|Chrome)(?:.+)Mobile/i,$a=/Mobile(?:.+)Firefox\b/i,Ha=function(i){return typeof i!="undefined"&&i.platform==="MacIntel"&&typeof i.maxTouchPoints=="number"&&i.maxTouchPoints>1&&typeof MSStream=="undefined"};function Hu(i){return function(t){return t.test(i)}}function Va(i){var t={userAgent:"",platform:"",maxTouchPoints:0};!i&&typeof navigator!="undefined"?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof i=="string"?t.userAgent=i:i&&i.userAgent&&(t={userAgent:i.userAgent,platform:i.platform,maxTouchPoints:i.maxTouchPoints||0});var e=t.userAgent,s=e.split("[FBAN");typeof s[1]!="undefined"&&(e=s[0]),s=e.split("Twitter"),typeof s[1]!="undefined"&&(e=s[0]);var r=Hu(e),n={apple:{phone:r(Ar)&&!r(he),ipod:r(Da),tablet:!r(Ar)&&(r(Oa)||Ha(t))&&!r(he),universal:r(Ba),device:(r(Ar)||r(Da)||r(Oa)||r(Ba)||Ha(t))&&!r(he)},amazon:{phone:r(ze),tablet:!r(ze)&&r(di),device:r(ze)||r(di)},android:{phone:!r(he)&&r(ze)||!r(he)&&r(wr),tablet:!r(he)&&!r(ze)&&!r(wr)&&(r(di)||r(Fa)),device:!r(he)&&(r(ze)||r(di)||r(wr)||r(Fa))||r(/\bokhttp\b/i)},windows:{phone:r(he),tablet:r(Na),device:r(he)||r(Na)},other:{blackberry:r(La),blackberry10:r(Ua),opera:r(ka),firefox:r($a),chrome:r(Ga),device:r(La)||r(Ua)||r(ka)||r($a)||r(Ga)},any:!1,phone:!1,tablet:!1};return n.any=n.apple.device||n.android.device||n.windows.device||n.other.device,n.phone=n.apple.phone||n.android.phone||n.windows.phone,n.tablet=n.apple.tablet||n.android.tablet||n.windows.tablet,n}var ja;const Xt=((ja=Va.default)!=null?ja:Va)(globalThis.navigator);N.RETINA_PREFIX=/@([0-9\.]+)x/,N.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT=!1;var Sr=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function We(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}function dg(i){return i&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}function fg(i){return i&&Object.prototype.hasOwnProperty.call(i,"default")&&Object.keys(i).length===1?i.default:i}function pg(i){if(i.__esModule)return i;var t=i.default;if(typeof t=="function"){var e=function s(){if(this instanceof s){var r=[null];r.push.apply(r,arguments);var n=Function.bind.apply(t,r);return new n}return t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(i).forEach(function(s){var r=Object.getOwnPropertyDescriptor(i,s);Object.defineProperty(e,s,r.get?r:{enumerable:!0,get:function(){return i[s]}})}),e}var Cr={exports:{}},mg=Cr.exports;(function(i){"use strict";var t=Object.prototype.hasOwnProperty,e="~";function s(){}Object.create&&(s.prototype=Object.create(null),new s().__proto__||(e=!1));function r(h,l,u){this.fn=h,this.context=l,this.once=u||!1}function n(h,l,u,c,d){if(typeof u!="function")throw new TypeError("The listener must be a function");var f=new r(u,c||h,d),p=e?e+l:l;return h._events[p]?h._events[p].fn?h._events[p]=[h._events[p],f]:h._events[p].push(f):(h._events[p]=f,h._eventsCount++),h}function a(h,l){--h._eventsCount===0?h._events=new s:delete h._events[l]}function o(){this._events=new s,this._eventsCount=0}o.prototype.eventNames=function(){var l=[],u,c;if(this._eventsCount===0)return l;for(c in u=this._events)t.call(u,c)&&l.push(e?c.slice(1):c);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(u)):l},o.prototype.listeners=function(l){var u=e?e+l:l,c=this._events[u];if(!c)return[];if(c.fn)return[c.fn];for(var d=0,f=c.length,p=new Array(f);d80*e){o=l=i[0],h=u=i[1];for(var p=e;pl&&(l=c),d>u&&(u=d);f=Math.max(l-o,u-h),f=f!==0?32767/f:0}return ls(n,a,e,o,h,f,0),a}function Xa(i,t,e,s,r){var n,a;if(r===Pr(i,t,e,s)>0)for(n=t;n=t;n-=s)a=Ya(n,i[n],i[n+1],a);return a&&mi(a,a.next)&&(cs(a),a=a.next),a}function De(i,t){if(!i)return i;t||(t=i);var e=i,s;do if(s=!1,!e.steiner&&(mi(e,e.next)||ct(e.prev,e,e.next)===0)){if(cs(e),e=t=e.prev,e===e.next)break;s=!0}else e=e.next;while(s||e!==t);return t}function ls(i,t,e,s,r,n,a){if(i){!a&&n&&Ju(i,s,r,n);for(var o=i,h,l;i.prev!==i.next;){if(h=i.prev,l=i.next,n?Xu(i,s,r,n):ju(i)){t.push(h.i/e|0),t.push(i.i/e|0),t.push(l.i/e|0),cs(i),i=l.next,o=l.next;continue}if(i=l,i===o){a?a===1?(i=zu(De(i),t,e),ls(i,t,e,s,r,n,2)):a===2&&Wu(i,t,e,s,r,n):ls(De(i),t,e,s,r,n,1);break}}}}function ju(i){var t=i.prev,e=i,s=i.next;if(ct(t,e,s)>=0)return!1;for(var r=t.x,n=e.x,a=s.x,o=t.y,h=e.y,l=s.y,u=rn?r>a?r:a:n>a?n:a,f=o>h?o>l?o:l:h>l?h:l,p=s.next;p!==t;){if(p.x>=u&&p.x<=d&&p.y>=c&&p.y<=f&&qe(r,o,n,h,a,l,p.x,p.y)&&ct(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Xu(i,t,e,s){var r=i.prev,n=i,a=i.next;if(ct(r,n,a)>=0)return!1;for(var o=r.x,h=n.x,l=a.x,u=r.y,c=n.y,d=a.y,f=oh?o>l?o:l:h>l?h:l,g=u>c?u>d?u:d:c>d?c:d,_=Rr(f,p,t,e,s),x=Rr(m,g,t,e,s),v=i.prevZ,b=i.nextZ;v&&v.z>=_&&b&&b.z<=x;){if(v.x>=f&&v.x<=m&&v.y>=p&&v.y<=g&&v!==r&&v!==a&&qe(o,u,h,c,l,d,v.x,v.y)&&ct(v.prev,v,v.next)>=0||(v=v.prevZ,b.x>=f&&b.x<=m&&b.y>=p&&b.y<=g&&b!==r&&b!==a&&qe(o,u,h,c,l,d,b.x,b.y)&&ct(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;v&&v.z>=_;){if(v.x>=f&&v.x<=m&&v.y>=p&&v.y<=g&&v!==r&&v!==a&&qe(o,u,h,c,l,d,v.x,v.y)&&ct(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;b&&b.z<=x;){if(b.x>=f&&b.x<=m&&b.y>=p&&b.y<=g&&b!==r&&b!==a&&qe(o,u,h,c,l,d,b.x,b.y)&&ct(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function zu(i,t,e){var s=i;do{var r=s.prev,n=s.next.next;!mi(r,n)&&za(r,s,s.next,n)&&us(r,n)&&us(n,r)&&(t.push(r.i/e|0),t.push(s.i/e|0),t.push(n.i/e|0),cs(s),cs(s.next),s=i=n),s=s.next}while(s!==i);return De(s)}function Wu(i,t,e,s,r,n){var a=i;do{for(var o=a.next.next;o!==a.prev;){if(a.i!==o.i&&sc(a,o)){var h=Wa(a,o);a=De(a,a.next),h=De(h,h.next),ls(a,t,e,s,r,n,0),ls(h,t,e,s,r,n,0);return}o=o.next}a=a.next}while(a!==i)}function Yu(i,t,e,s){var r=[],n,a,o,h,l;for(n=0,a=t.length;n=e.next.y&&e.next.y!==e.y){var o=e.x+(r-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(o<=s&&o>n&&(n=o,a=e.x=e.x&&e.x>=l&&s!==e.x&&qe(ra.x||e.x===a.x&&Qu(a,e)))&&(a=e,c=d)),e=e.next;while(e!==h);return a}function Qu(i,t){return ct(i.prev,i,t.prev)<0&&ct(t.next,i,i.next)<0}function Ju(i,t,e,s){var r=i;do r.z===0&&(r.z=Rr(r.x,r.y,t,e,s)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,tc(r)}function tc(i){var t,e,s,r,n,a,o,h,l=1;do{for(e=i,i=null,n=null,a=0;e;){for(a++,s=e,o=0,t=0;t0||h>0&&s;)o!==0&&(h===0||!s||e.z<=s.z)?(r=e,e=e.nextZ,o--):(r=s,s=s.nextZ,h--),n?n.nextZ=r:i=r,r.prevZ=n,n=r;e=s}n.nextZ=null,l*=2}while(a>1);return i}function Rr(i,t,e,s,r){return i=(i-e)*r|0,t=(t-s)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,i|t<<1}function ec(i){var t=i,e=i;do(t.x=(i-a)*(n-o)&&(i-a)*(s-o)>=(e-a)*(t-o)&&(e-a)*(n-o)>=(r-a)*(s-o)}function sc(i,t){return i.next.i!==t.i&&i.prev.i!==t.i&&!ic(i,t)&&(us(i,t)&&us(t,i)&&rc(i,t)&&(ct(i.prev,i,t.prev)||ct(i,t.prev,t))||mi(i,t)&&ct(i.prev,i,i.next)>0&&ct(t.prev,t,t.next)>0)}function ct(i,t,e){return(t.y-i.y)*(e.x-t.x)-(t.x-i.x)*(e.y-t.y)}function mi(i,t){return i.x===t.x&&i.y===t.y}function za(i,t,e,s){var r=_i(ct(i,t,e)),n=_i(ct(i,t,s)),a=_i(ct(e,s,i)),o=_i(ct(e,s,t));return!!(r!==n&&a!==o||r===0&&gi(i,e,t)||n===0&&gi(i,s,t)||a===0&&gi(e,i,s)||o===0&&gi(e,t,s))}function gi(i,t,e){return t.x<=Math.max(i.x,e.x)&&t.x>=Math.min(i.x,e.x)&&t.y<=Math.max(i.y,e.y)&&t.y>=Math.min(i.y,e.y)}function _i(i){return i>0?1:i<0?-1:0}function ic(i,t){var e=i;do{if(e.i!==i.i&&e.next.i!==i.i&&e.i!==t.i&&e.next.i!==t.i&&za(e,e.next,i,t))return!0;e=e.next}while(e!==i);return!1}function us(i,t){return ct(i.prev,i,i.next)<0?ct(i,t,i.next)>=0&&ct(i,i.prev,t)>=0:ct(i,t,i.prev)<0||ct(i,i.next,t)<0}function rc(i,t){var e=i,s=!1,r=(i.x+t.x)/2,n=(i.y+t.y)/2;do e.y>n!=e.next.y>n&&e.next.y!==e.y&&r<(e.next.x-e.x)*(n-e.y)/(e.next.y-e.y)+e.x&&(s=!s),e=e.next;while(e!==i);return s}function Wa(i,t){var e=new Ir(i.i,i.x,i.y),s=new Ir(t.i,t.x,t.y),r=i.next,n=t.prev;return i.next=t,t.prev=i,e.next=r,r.prev=e,s.next=e,e.prev=s,n.next=s,s.prev=n,s}function Ya(i,t,e,s){var r=new Ir(i,t,e);return s?(r.next=s.next,r.prev=s,s.next.prev=r,s.next=r):(r.prev=r,r.next=r),r}function cs(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function Ir(i,t,e){this.i=i,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}pi.deviation=function(i,t,e,s){var r=t&&t.length,n=r?t[0]*e:i.length,a=Math.abs(Pr(i,0,n,e));if(r)for(var o=0,h=t.length;o0&&(s+=i[r-1].length,e.holes.push(s))}return e};var nc=fi.exports,qa=We(nc),ds={},vi={exports:{}};/*! https://mths.be/punycode v1.3.2 by @mathias */var vg=vi.exports;(function(i,t){(function(e){var s=t&&!t.nodeType&&t,r=i&&!i.nodeType&&i,n=typeof Sr=="object"&&Sr;(n.global===n||n.window===n||n.self===n)&&(e=n);var a,o=2147483647,h=36,l=1,u=26,c=38,d=700,f=72,p=128,m="-",g=/^xn--/,_=/[^\x20-\x7E]/,x=/[\x2E\u3002\uFF0E\uFF61]/g,v={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},b=h-l,T=Math.floor,R=String.fromCharCode,w;function A(F){throw RangeError(v[F])}function S(F,O){for(var Z=F.length,Q=[];Z--;)Q[Z]=O(F[Z]);return Q}function I(F,O){var Z=F.split("@"),Q="";Z.length>1&&(Q=Z[0]+"@",F=Z[1]),F=F.replace(x,".");var J=F.split("."),st=S(J,O).join(".");return Q+st}function H(F){for(var O=[],Z=0,Q=F.length,J,st;Z=55296&&J<=56319&&Z65535&&(O-=65536,Z+=R(O>>>10&1023|55296),O=56320|O&1023),Z+=R(O),Z}).join("")}function E(F){return F-48<10?F-22:F-65<26?F-65:F-97<26?F-97:h}function P(F,O){return F+22+75*(F<26)-((O!=0)<<5)}function V(F,O,Z){var Q=0;for(F=Z?T(F/d):F>>1,F+=T(F/O);F>b*u>>1;Q+=h)F=T(F/b);return T(Q+(b+1)*F/(F+c))}function q(F){var O=[],Z=F.length,Q,J=0,st=p,et=f,rt,lt,_t,nt,ut,mt,vt,ne,ae;for(rt=F.lastIndexOf(m),rt<0&&(rt=0),lt=0;lt=128&&A("not-basic"),O.push(F.charCodeAt(lt));for(_t=rt>0?rt+1:0;_t=Z&&A("invalid-input"),vt=E(F.charCodeAt(_t++)),(vt>=h||vt>T((o-J)/ut))&&A("overflow"),J+=vt*ut,ne=mt<=et?l:mt>=et+u?u:mt-et,!(vtT(o/ae)&&A("overflow"),ut*=ae;Q=O.length+1,et=V(J-nt,Q,nt==0),T(J/Q)>o-st&&A("overflow"),st+=T(J/Q),J%=Q,O.splice(J++,0,st)}return B(O)}function j(F){var O,Z,Q,J,st,et,rt,lt,_t,nt,ut,mt=[],vt,ne,ae,ii;for(F=H(F),vt=F.length,O=p,Z=0,st=f,et=0;et=O&&utT((o-Z)/ne)&&A("overflow"),Z+=(rt-O)*ne,O=rt,et=0;eto&&A("overflow"),ut==O){for(lt=Z,_t=h;nt=_t<=st?l:_t>=st+u?u:_t-st,!(lt0&&o>a&&(o=a);for(var h=0;h=0?(c=l.substr(0,u),d=l.substr(u+1)):(c=l,d=""),f=decodeURIComponent(c),p=decodeURIComponent(d),ac(r,f)?Array.isArray(r[f])?r[f].push(p):r[f]=[r[f],p]:r[f]=p}return r},bg=We(Qa),ps=function(i){switch(typeof i){case"string":return i;case"boolean":return i?"true":"false";case"number":return isFinite(i)?i:"";default:return""}},Ja=function(i,t,e,s){return t=t||"&",e=e||"=",i===null&&(i=void 0),typeof i=="object"?Object.keys(i).map(function(r){var n=encodeURIComponent(ps(r))+e;return Array.isArray(i[r])?i[r].map(function(a){return n+encodeURIComponent(ps(a))}).join(t):n+encodeURIComponent(ps(i[r]))}).join(t):s?encodeURIComponent(ps(s))+e+encodeURIComponent(ps(i)):""},Tg=We(Ja),oc,hc,Eg=fs.decode=hc=fs.parse=Qa,Ag=fs.encode=oc=fs.stringify=Ja,lc=Ka,Qt=Za,uc=ds.parse=ms,cc=ds.resolve=Tc,wg=ds.resolveObject=Ec,dc=ds.format=bc,Sg=ds.Url=Ft;function Ft(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var fc=/^([a-z0-9.+-]+:)/i,pc=/:[0-9]*$/,mc=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,gc=["<",">",'"',"`"," ","\r",` +`," "],_c=["{","}","|","\\","^","`"].concat(gc),Mr=["'"].concat(_c),to=["%","/","?",";","#"].concat(Mr),eo=["/","?","#"],vc=255,so=/^[+a-z0-9A-Z_-]{0,63}$/,yc=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,xc={javascript:!0,"javascript:":!0},Dr={javascript:!0,"javascript:":!0},Ke={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},Or=fs;function ms(i,t,e){if(i&&Qt.isObject(i)&&i instanceof Ft)return i;var s=new Ft;return s.parse(i,t,e),s}Ft.prototype.parse=function(i,t,e){if(!Qt.isString(i))throw new TypeError("Parameter 'url' must be a string, not "+typeof i);var s=i.indexOf("?"),r=s!==-1&&s127?T+="x":T+=b[R];if(!T.match(so)){var A=x.slice(0,f),S=x.slice(f+1),I=b.match(yc);I&&(A.push(I[1]),S.unshift(I[2])),S.length&&(o="/"+S.join(".")+o),this.hostname=A.join(".");break}}}this.hostname.length>vc?this.hostname="":this.hostname=this.hostname.toLowerCase(),_||(this.hostname=lc.toASCII(this.hostname));var H=this.port?":"+this.port:"",B=this.hostname||"";this.host=B+H,this.href+=this.host,_&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),o[0]!=="/"&&(o="/"+o))}if(!xc[u])for(var f=0,v=Mr.length;f0?e.host.split("@"):!1;T&&(e.auth=T.shift(),e.host=e.hostname=T.shift())}return e.search=i.search,e.query=i.query,(!Qt.isNull(e.pathname)||!Qt.isNull(e.search))&&(e.path=(e.pathname?e.pathname:"")+(e.search?e.search:"")),e.href=e.format(),e}if(!x.length)return e.pathname=null,e.search?e.path="/"+e.search:e.path=null,e.href=e.format(),e;for(var R=x.slice(-1)[0],w=(e.host||i.host||x.length>1)&&(R==="."||R==="..")||R==="",A=0,S=x.length;S>=0;S--)R=x[S],R==="."?x.splice(S,1):R===".."?(x.splice(S,1),A++):A&&(x.splice(S,1),A--);if(!g&&!_)for(;A--;A)x.unshift("..");g&&x[0]!==""&&(!x[0]||x[0].charAt(0)!=="/")&&x.unshift(""),w&&x.join("/").substr(-1)!=="/"&&x.push("");var I=x[0]===""||x[0]&&x[0].charAt(0)==="/";if(b){e.hostname=e.host=I?"":x.length?x.shift():"";var T=e.host&&e.host.indexOf("@")>0?e.host.split("@"):!1;T&&(e.auth=T.shift(),e.host=e.hostname=T.shift())}return g=g||e.host&&x.length,g&&!I&&x.unshift(""),x.length?e.pathname=x.join("/"):(e.pathname=null,e.path=null),(!Qt.isNull(e.pathname)||!Qt.isNull(e.search))&&(e.path=(e.pathname?e.pathname:"")+(e.search?e.search:"")),e.auth=i.auth||e.auth,e.slashes=e.slashes||i.slashes,e.href=e.format(),e},Ft.prototype.parseHost=function(){var i=this.host,t=pc.exec(i);t&&(t=t[0],t!==":"&&(this.port=t.substr(1)),i=i.substr(0,i.length-t.length)),i&&(this.hostname=i)};const io={};function ro(i,t,e=3){if(io[t])return;let s=new Error().stack;typeof s=="undefined"?console.warn("PixiJS Deprecation Warning: ",`${t} +Deprecated since v${i}`):(s=s.split(` +`).splice(e).join(` +`),console.groupCollapsed?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",`${t} +Deprecated since v${i}`),console.warn(s),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",`${t} +Deprecated since v${i}`),console.warn(s))),io[t]=!0}const Ac={get parse(){return uc},get format(){return dc},get resolve(){return cc}};function zt(i){if(typeof i!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(i)}`)}function gs(i){return i.split("?")[0].split("#")[0]}function wc(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Sc(i,t,e){return i.replace(new RegExp(wc(t),"g"),e)}function Cc(i,t){let e="",s=0,r=-1,n=0,a=-1;for(let o=0;o<=i.length;++o){if(o2){const h=e.lastIndexOf("/");if(h!==e.length-1){h===-1?(e="",s=0):(e=e.slice(0,h),s=e.length-1-e.lastIndexOf("/")),r=o,n=0;continue}}else if(e.length===2||e.length===1){e="",s=0,r=o,n=0;continue}}t&&(e.length>0?e+="/..":e="..",s=2)}else e.length>0?e+=`/${i.slice(r+1,o)}`:e=i.slice(r+1,o),s=o-r-1;r=o,n=0}else a===46&&n!==-1?++n:n=-1}return e}const bt={toPosix(i){return Sc(i,"\\","/")},isUrl(i){return/^https?:/.test(this.toPosix(i))},isDataUrl(i){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(i)},isBlobUrl(i){return i.startsWith("blob:")},hasProtocol(i){return/^[^/:]+:/.test(this.toPosix(i))},getProtocol(i){zt(i),i=this.toPosix(i);const t=/^file:\/\/\//.exec(i);if(t)return t[0];const e=/^[^/:]+:\/{0,2}/.exec(i);return e?e[0]:""},toAbsolute(i,t,e){if(zt(i),this.isDataUrl(i)||this.isBlobUrl(i))return i;const s=gs(this.toPosix(t!=null?t:N.ADAPTER.getBaseUrl())),r=gs(this.toPosix(e!=null?e:this.rootname(s)));return i=this.toPosix(i),i.startsWith("/")?bt.join(r,i.slice(1)):this.isAbsolute(i)?i:this.join(s,i)},normalize(i){if(zt(i),i.length===0)return".";if(this.isDataUrl(i)||this.isBlobUrl(i))return i;i=this.toPosix(i);let t="";const e=i.startsWith("/");this.hasProtocol(i)&&(t=this.rootname(i),i=i.slice(t.length));const s=i.endsWith("/");return i=Cc(i,!1),i.length>0&&s&&(i+="/"),e?`/${i}`:t+i},isAbsolute(i){return zt(i),i=this.toPosix(i),this.hasProtocol(i)?!0:i.startsWith("/")},join(...i){var t;if(i.length===0)return".";let e;for(let s=0;s0)if(e===void 0)e=r;else{const n=(t=i[s-1])!=null?t:"";this.extname(n)?e+=`/../${r}`:e+=`/${r}`}}return e===void 0?".":this.normalize(e)},dirname(i){if(zt(i),i.length===0)return".";i=this.toPosix(i);let t=i.charCodeAt(0);const e=t===47;let s=-1,r=!0;const n=this.getProtocol(i),a=i;i=i.slice(n.length);for(let o=i.length-1;o>=1;--o)if(t=i.charCodeAt(o),t===47){if(!r){s=o;break}}else r=!1;return s===-1?e?"/":this.isUrl(a)?n+i:n:e&&s===1?"//":n+i.slice(0,s)},rootname(i){zt(i),i=this.toPosix(i);let t="";if(i.startsWith("/")?t="/":t=this.getProtocol(i),this.isUrl(i)){const e=i.indexOf("/",t.length);e!==-1?t=i.slice(0,e):t=i,t.endsWith("/")||(t+="/")}return t},basename(i,t){zt(i),t&&zt(t),i=gs(this.toPosix(i));let e=0,s=-1,r=!0,n;if(t!==void 0&&t.length>0&&t.length<=i.length){if(t.length===i.length&&t===i)return"";let a=t.length-1,o=-1;for(n=i.length-1;n>=0;--n){const h=i.charCodeAt(n);if(h===47){if(!r){e=n+1;break}}else o===-1&&(r=!1,o=n+1),a>=0&&(h===t.charCodeAt(a)?--a===-1&&(s=n):(a=-1,s=o))}return e===s?s=o:s===-1&&(s=i.length),i.slice(e,s)}for(n=i.length-1;n>=0;--n)if(i.charCodeAt(n)===47){if(!r){e=n+1;break}}else s===-1&&(r=!1,s=n+1);return s===-1?"":i.slice(e,s)},extname(i){zt(i),i=gs(this.toPosix(i));let t=-1,e=0,s=-1,r=!0,n=0;for(let a=i.length-1;a>=0;--a){const o=i.charCodeAt(a);if(o===47){if(!r){e=a+1;break}continue}s===-1&&(r=!1,s=a+1),o===46?t===-1?t=a:n!==1&&(n=1):t!==-1&&(n=-1)}return t===-1||s===-1||n===0||n===1&&t===s-1&&t===e+1?"":i.slice(t,s)},parse(i){zt(i);const t={root:"",dir:"",base:"",ext:"",name:""};if(i.length===0)return t;i=gs(this.toPosix(i));let e=i.charCodeAt(0);const s=this.isAbsolute(i);let r;const n="";t.root=this.rootname(i),s||this.hasProtocol(i)?r=1:r=0;let a=-1,o=0,h=-1,l=!0,u=i.length-1,c=0;for(;u>=r;--u){if(e=i.charCodeAt(u),e===47){if(!l){o=u+1;break}continue}h===-1&&(l=!1,h=u+1),e===46?a===-1?a=u:c!==1&&(c=1):a!==-1&&(c=-1)}return a===-1||h===-1||c===0||c===1&&a===h-1&&a===o+1?h!==-1&&(o===0&&s?t.base=t.name=i.slice(1,h):t.base=t.name=i.slice(o,h)):(o===0&&s?(t.name=i.slice(1,a),t.base=i.slice(1,h)):(t.name=i.slice(o,a),t.base=i.slice(o,h)),t.ext=i.slice(a,h)),t.dir=this.dirname(i),n&&(t.dir=n+t.dir),t},sep:"/",delimiter:":"};let Br;async function no(){return Br!=null||(Br=(async()=>{var i;const t=document.createElement("canvas").getContext("webgl");if(!t)return At.UNPACK;const e=await new Promise(a=>{const o=document.createElement("video");o.onloadeddata=()=>a(o),o.onerror=()=>a(null),o.autoplay=!1,o.crossOrigin="anonymous",o.preload="auto",o.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",o.load()});if(!e)return At.UNPACK;const s=t.createTexture();t.bindTexture(t.TEXTURE_2D,s);const r=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,r),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,s,0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,t.NONE),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e);const n=new Uint8Array(4);return t.readPixels(0,0,1,1,t.RGBA,t.UNSIGNED_BYTE,n),t.deleteFramebuffer(r),t.deleteTexture(s),(i=t.getExtension("WEBGL_lose_context"))==null||i.loseContext(),n[0]<=n[3]?At.PMA:At.UNPACK})()),Br}function Rc(){}function Ic(){}let Fr;function ao(){return typeof Fr=="undefined"&&(Fr=function(){var i;const t={stencil:!0,failIfMajorPerformanceCaveat:N.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT};try{if(!N.ADAPTER.getWebGLRenderingContext())return!1;const e=N.ADAPTER.createCanvas();let s=e.getContext("webgl",t)||e.getContext("experimental-webgl",t);const r=!!((i=s==null?void 0:s.getContextAttributes())!=null&&i.stencil);if(s){const n=s.getExtension("WEBGL_lose_context");n&&n.loseContext()}return s=null,r}catch(e){return!1}}()),Fr}var Pc={grad:.9,turn:360,rad:360/(2*Math.PI)},le=function(i){return typeof i=="string"?i.length>0:typeof i=="number"},yt=function(i,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*i)/e+0},Nt=function(i,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),i>e?e:i>t?i:t},oo=function(i){return(i=isFinite(i)?i%360:0)>0?i:i+360},ho=function(i){return{r:Nt(i.r,0,255),g:Nt(i.g,0,255),b:Nt(i.b,0,255),a:Nt(i.a)}},Nr=function(i){return{r:yt(i.r),g:yt(i.g),b:yt(i.b),a:yt(i.a,3)}},Mc=/^#([0-9a-f]{3,8})$/i,yi=function(i){var t=i.toString(16);return t.length<2?"0"+t:t},lo=function(i){var t=i.r,e=i.g,s=i.b,r=i.a,n=Math.max(t,e,s),a=n-Math.min(t,e,s),o=a?n===t?(e-s)/a:n===e?2+(s-t)/a:4+(t-e)/a:0;return{h:60*(o<0?o+6:o),s:n?a/n*100:0,v:n/255*100,a:r}},uo=function(i){var t=i.h,e=i.s,s=i.v,r=i.a;t=t/360*6,e/=100,s/=100;var n=Math.floor(t),a=s*(1-e),o=s*(1-(t-n)*e),h=s*(1-(1-t+n)*e),l=n%6;return{r:255*[s,o,a,a,h,s][l],g:255*[h,s,s,o,a,a][l],b:255*[a,a,h,s,s,o][l],a:r}},co=function(i){return{h:oo(i.h),s:Nt(i.s,0,100),l:Nt(i.l,0,100),a:Nt(i.a)}},fo=function(i){return{h:yt(i.h),s:yt(i.s),l:yt(i.l),a:yt(i.a,3)}},po=function(i){return uo((e=(t=i).s,{h:t.h,s:(e*=((s=t.l)<50?s:100-s)/100)>0?2*e/(s+e)*100:0,v:s+e,a:t.a}));var t,e,s},_s=function(i){return{h:(t=lo(i)).h,s:(r=(200-(e=t.s))*(s=t.v)/100)>0&&r<200?e*s/100/(r<=100?r:200-r)*100:0,l:r/2,a:t.a};var t,e,s,r},Dc=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Oc=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Bc=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Fc=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Lr={string:[[function(i){var t=Mc.exec(i);return t?(i=t[1]).length<=4?{r:parseInt(i[0]+i[0],16),g:parseInt(i[1]+i[1],16),b:parseInt(i[2]+i[2],16),a:i.length===4?yt(parseInt(i[3]+i[3],16)/255,2):1}:i.length===6||i.length===8?{r:parseInt(i.substr(0,2),16),g:parseInt(i.substr(2,2),16),b:parseInt(i.substr(4,2),16),a:i.length===8?yt(parseInt(i.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(i){var t=Bc.exec(i)||Fc.exec(i);return t?t[2]!==t[4]||t[4]!==t[6]?null:ho({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(i){var t=Dc.exec(i)||Oc.exec(i);if(!t)return null;var e,s,r=co({h:(e=t[1],s=t[2],s===void 0&&(s="deg"),Number(e)*(Pc[s]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return po(r)},"hsl"]],object:[[function(i){var t=i.r,e=i.g,s=i.b,r=i.a,n=r===void 0?1:r;return le(t)&&le(e)&&le(s)?ho({r:Number(t),g:Number(e),b:Number(s),a:Number(n)}):null},"rgb"],[function(i){var t=i.h,e=i.s,s=i.l,r=i.a,n=r===void 0?1:r;if(!le(t)||!le(e)||!le(s))return null;var a=co({h:Number(t),s:Number(e),l:Number(s),a:Number(n)});return po(a)},"hsl"],[function(i){var t=i.h,e=i.s,s=i.v,r=i.a,n=r===void 0?1:r;if(!le(t)||!le(e)||!le(s))return null;var a=function(o){return{h:oo(o.h),s:Nt(o.s,0,100),v:Nt(o.v,0,100),a:Nt(o.a)}}({h:Number(t),s:Number(e),v:Number(s),a:Number(n)});return uo(a)},"hsv"]]},mo=function(i,t){for(var e=0;e=.5},i.prototype.toHex=function(){return t=Nr(this.rgba),e=t.r,s=t.g,r=t.b,a=(n=t.a)<1?yi(yt(255*n)):"","#"+yi(e)+yi(s)+yi(r)+a;var t,e,s,r,n,a},i.prototype.toRgb=function(){return Nr(this.rgba)},i.prototype.toRgbString=function(){return t=Nr(this.rgba),e=t.r,s=t.g,r=t.b,(n=t.a)<1?"rgba("+e+", "+s+", "+r+", "+n+")":"rgb("+e+", "+s+", "+r+")";var t,e,s,r,n},i.prototype.toHsl=function(){return fo(_s(this.rgba))},i.prototype.toHslString=function(){return t=fo(_s(this.rgba)),e=t.h,s=t.s,r=t.l,(n=t.a)<1?"hsla("+e+", "+s+"%, "+r+"%, "+n+")":"hsl("+e+", "+s+"%, "+r+"%)";var t,e,s,r,n},i.prototype.toHsv=function(){return t=lo(this.rgba),{h:yt(t.h),s:yt(t.s),v:yt(t.v),a:yt(t.a,3)};var t},i.prototype.invert=function(){return Jt({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},i.prototype.saturate=function(t){return t===void 0&&(t=.1),Jt(Ur(this.rgba,t))},i.prototype.desaturate=function(t){return t===void 0&&(t=.1),Jt(Ur(this.rgba,-t))},i.prototype.grayscale=function(){return Jt(Ur(this.rgba,-1))},i.prototype.lighten=function(t){return t===void 0&&(t=.1),Jt(_o(this.rgba,t))},i.prototype.darken=function(t){return t===void 0&&(t=.1),Jt(_o(this.rgba,-t))},i.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},i.prototype.alpha=function(t){return typeof t=="number"?Jt({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):yt(this.rgba.a,3);var e},i.prototype.hue=function(t){var e=_s(this.rgba);return typeof t=="number"?Jt({h:t,s:e.s,l:e.l,a:e.a}):yt(e.h)},i.prototype.isEqual=function(t){return this.toHex()===Jt(t).toHex()},i}(),Jt=function(i){return i instanceof xi?i:new xi(i)},vo=[],Nc=function(i){i.forEach(function(t){vo.indexOf(t)<0&&(t(xi,Lr),vo.push(t))})},Rg=function(){return new xi({r:255*Math.random(),g:255*Math.random(),b:255*Math.random()})};function Lc(i,t){var e={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},s={};for(var r in e)s[e[r]]=r;var n={};i.prototype.toName=function(a){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var o,h,l=s[this.toHex()];if(l)return l;if(a!=null&&a.closest){var u=this.toRgb(),c=1/0,d="black";if(!n.length)for(var f in e)n[f]=new i(e[f]).toRgb();for(var p in e){var m=(o=u,h=n[p],Math.pow(o.r-h.r,2)+Math.pow(o.g-h.g,2)+Math.pow(o.b-h.b,2));mt in i?Uc(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,$c=(i,t)=>{for(var e in t||(t={}))kc.call(t,e)&&xo(i,e,t[e]);if(yo)for(var e of yo(t))Gc.call(t,e)&&xo(i,e,t[e]);return i};Nc([Lc]);const Ze=class yr{constructor(t=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=t}get red(){return this._components[0]}get green(){return this._components[1]}get blue(){return this._components[2]}get alpha(){return this._components[3]}setValue(t){return this.value=t,this}set value(t){if(t instanceof yr)this._value=this.cloneSource(t._value),this._int=t._int,this._components.set(t._components);else{if(t===null)throw new Error("Cannot set PIXI.Color#value to null");(this._value===null||!this.isSourceEqual(this._value,t))&&(this.normalize(t),this._value=this.cloneSource(t))}}get value(){return this._value}cloneSource(t){return typeof t=="string"||typeof t=="number"||t instanceof Number||t===null?t:Array.isArray(t)||ArrayBuffer.isView(t)?t.slice(0):typeof t=="object"&&t!==null?$c({},t):t}isSourceEqual(t,e){const s=typeof t;if(s!==typeof e)return!1;if(s==="number"||s==="string"||t instanceof Number)return t===e;if(Array.isArray(t)&&Array.isArray(e)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(e))return t.length!==e.length?!1:t.every((r,n)=>r===e[n]);if(t!==null&&e!==null){const r=Object.keys(t),n=Object.keys(e);return r.length!==n.length?!1:r.every(a=>t[a]===e[a])}return t===e}toRgba(){const[t,e,s,r]=this._components;return{r:t,g:e,b:s,a:r}}toRgb(){const[t,e,s]=this._components;return{r:t,g:e,b:s}}toRgbaString(){const[t,e,s]=this.toUint8RgbArray();return`rgba(${t},${e},${s},${this.alpha})`}toUint8RgbArray(t){const[e,s,r]=this._components;return t=t!=null?t:[],t[0]=Math.round(e*255),t[1]=Math.round(s*255),t[2]=Math.round(r*255),t}toRgbArray(t){t=t!=null?t:[];const[e,s,r]=this._components;return t[0]=e,t[1]=s,t[2]=r,t}toNumber(){return this._int}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,s,r,n]=yr.temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=s,this._components[2]*=r,this._components[3]*=n,this.refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this.refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(t===1)return(255<<24)+this._int;if(t===0)return e?0:this._int;let s=this._int>>16&255,r=this._int>>8&255,n=this._int&255;return e&&(s=s*t+.5|0,r=r*t+.5|0,n=n*t+.5|0),(t*255<<24)+(s<<16)+(r<<8)+n}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const t=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-t.length)+t}setAlpha(t){return this._components[3]=this._clamp(t),this}round(t){const[e,s,r]=this._components;return this._components[0]=Math.round(e*t)/t,this._components[1]=Math.round(s*t)/t,this._components[2]=Math.round(r*t)/t,this.refreshInt(),this._value=null,this}toArray(t){t=t!=null?t:[];const[e,s,r,n]=this._components;return t[0]=e,t[1]=s,t[2]=r,t[3]=n,t}normalize(t){let e,s,r,n;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const a=t;e=(a>>16&255)/255,s=(a>>8&255)/255,r=(a&255)/255,n=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,s,r,n=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,s,r,n=255]=t,e/=255,s/=255,r/=255,n/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const o=yr.HEX_PATTERN.exec(t);o&&(t=`#${o[2]}`)}const a=Jt(t);a.isValid()&&({r:e,g:s,b:r,a:n}=a.rgba,e/=255,s/=255,r/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=s,this._components[2]=r,this._components[3]=n,this.refreshInt();else throw new Error(`Unable to convert color ${t}`)}refreshInt(){this._clamp(this._components);const[t,e,s]=this._components;this._int=(t*255<<16)+(e*255<<8)+(s*255|0)}_clamp(t,e=0,s=1){return typeof t=="number"?Math.min(Math.max(t,e),s):(t.forEach((r,n)=>{t[n]=Math.min(Math.max(r,e),s)}),t)}};Ze.shared=new Ze,Ze.temp=new Ze,Ze.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let Y=Ze;function Hc(i,t=[]){return Y.shared.setValue(i).toRgbArray(t)}function bo(i){return Y.shared.setValue(i).toHex()}function Vc(i){return Y.shared.setValue(i).toNumber()}function To(i){return Y.shared.setValue(i).toNumber()}function jc(){const i=[],t=[];for(let s=0;s<32;s++)i[s]=s,t[s]=s;i[C.NORMAL_NPM]=C.NORMAL,i[C.ADD_NPM]=C.ADD,i[C.SCREEN_NPM]=C.SCREEN,t[C.NORMAL]=C.NORMAL_NPM,t[C.ADD]=C.ADD_NPM,t[C.SCREEN]=C.SCREEN_NPM;const e=[];return e.push(t),e.push(i),e}const Gr=jc();function $r(i,t){return Gr[t?1:0][i]}function Xc(i,t,e,s=!0){return Y.shared.setValue(i).premultiply(t,s).toArray(e!=null?e:new Float32Array(4))}function zc(i,t){return Y.shared.setValue(i).toPremultiplied(t)}function Wc(i,t,e,s=!0){return Y.shared.setValue(i).premultiply(t,s).toArray(e!=null?e:new Float32Array(4))}const Eo=/^\s*data:(?:([\w-]+)\/([\w+.-]+))?(?:;charset=([\w-]+))?(?:;(base64))?,(.*)/i;function Ao(i,t=null){const e=i*6;if(t=t||new Uint16Array(e),t.length!==e)throw new Error(`Out buffer length is incorrect, got ${t.length} and expected ${e}`);for(let s=0,r=0;s>>1,i|=i>>>2,i|=i>>>4,i|=i>>>8,i|=i>>>16,i+1}function Hr(i){return!(i&i-1)&&!!i}function Vr(i){let t=(i>65535?1:0)<<4;i>>>=t;let e=(i>255?1:0)<<3;return i>>>=e,t|=e,e=(i>15?1:0)<<2,i>>>=e,t|=e,e=(i>3?1:0)<<1,i>>>=e,t|=e,t|i>>1}function Oe(i,t,e){const s=i.length;let r;if(t>=s||e===0)return;e=t+e>s?s-t:e;const n=s-e;for(r=t;rt in i?td(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,Oo=(i,t)=>{for(var e in t||(t={}))id.call(t,e)&&Do(i,e,t[e]);if(Mo)for(var e of Mo(t))rd.call(t,e)&&Do(i,e,t[e]);return i},nd=(i,t)=>ed(i,sd(t)),D=(i=>(i.Renderer="renderer",i.Application="application",i.RendererSystem="renderer-webgl-system",i.RendererPlugin="renderer-webgl-plugin",i.CanvasRendererSystem="renderer-canvas-system",i.CanvasRendererPlugin="renderer-canvas-plugin",i.Asset="asset",i.LoadParser="load-parser",i.ResolveParser="resolve-parser",i.CacheParser="cache-parser",i.DetectionParser="detection-parser",i))(D||{});const Wr=i=>{if(typeof i=="function"||typeof i=="object"&&i.extension){const t=typeof i.extension!="object"?{type:i.extension}:i.extension;i=nd(Oo({},t),{ref:i})}if(typeof i=="object")i=Oo({},i);else throw new Error("Invalid extension type");return typeof i.type=="string"&&(i.type=[i.type]),i},Bo=(i,t)=>{var e;return(e=Wr(i).priority)!=null?e:t},U={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...i){return i.map(Wr).forEach(t=>{t.type.forEach(e=>{var s,r;return(r=(s=this._removeHandlers)[e])==null?void 0:r.call(s,t)})}),this},add(...i){return i.map(Wr).forEach(t=>{t.type.forEach(e=>{const s=this._addHandlers,r=this._queue;s[e]?s[e](t):(r[e]=r[e]||[],r[e].push(t))})}),this},handle(i,t,e){const s=this._addHandlers,r=this._removeHandlers;s[i]=t,r[i]=e;const n=this._queue;return n[i]&&(n[i].forEach(a=>t(a)),delete n[i]),this},handleByMap(i,t){return this.handle(i,e=>{t[e.name]=e.ref},e=>{delete t[e.name]})},handleByList(i,t,e=-1){return this.handle(i,s=>{t.includes(s.ref)||(t.push(s.ref),t.sort((r,n)=>Bo(n,e)-Bo(r,e)))},s=>{const r=t.indexOf(s.ref);r!==-1&&t.splice(r,1)})}};class Ti{constructor(t){typeof t=="number"?this.rawBinaryData=new ArrayBuffer(t):t instanceof Uint8Array?this.rawBinaryData=t.buffer:this.rawBinaryData=t,this.uint32View=new Uint32Array(this.rawBinaryData),this.float32View=new Float32Array(this.rawBinaryData)}get int8View(){return this._int8View||(this._int8View=new Int8Array(this.rawBinaryData)),this._int8View}get uint8View(){return this._uint8View||(this._uint8View=new Uint8Array(this.rawBinaryData)),this._uint8View}get int16View(){return this._int16View||(this._int16View=new Int16Array(this.rawBinaryData)),this._int16View}get uint16View(){return this._uint16View||(this._uint16View=new Uint16Array(this.rawBinaryData)),this._uint16View}get int32View(){return this._int32View||(this._int32View=new Int32Array(this.rawBinaryData)),this._int32View}view(t){return this[`${t}View`]}destroy(){this.rawBinaryData=null,this._int8View=null,this._uint8View=null,this._int16View=null,this._uint16View=null,this._int32View=null,this.uint32View=null,this.float32View=null}static sizeOf(t){switch(t){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw new Error(`${t} isn't a valid view type`)}}}const ad=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(` +`);function od(i){let t="";for(let e=0;e0&&(t+=` +else `),e=0;--s){const r=Ei[s];if(r.test&&r.test(i,e))return new r(i,t)}throw new Error("Unrecognized source type to auto-detect Resource")}class Pt{constructor(t){this.items=[],this._name=t,this._aliasCount=0}emit(t,e,s,r,n,a,o,h){if(arguments.length>8)throw new Error("max arguments reached");const{name:l,items:u}=this;this._aliasCount++;for(let c=0,d=u.length;c0&&this.items.length>1&&(this._aliasCount=0,this.items=this.items.slice(0))}add(t){return t[this._name]&&(this.ensureNonAliasedItems(),this.remove(t),this.items.push(t)),this}remove(t){const e=this.items.indexOf(t);return e!==-1&&(this.ensureNonAliasedItems(),this.items.splice(e,1)),this}contains(t){return this.items.includes(t)}removeAll(){return this.ensureNonAliasedItems(),this.items.length=0,this}destroy(){this.removeAll(),this.items=null,this._name=null}get empty(){return this.items.length===0}get name(){return this._name}}Object.defineProperties(Pt.prototype,{dispatch:{value:Pt.prototype.emit},run:{value:Pt.prototype.emit}});class Qe{constructor(t=0,e=0){this._width=t,this._height=e,this.destroyed=!1,this.internal=!1,this.onResize=new Pt("setRealSize"),this.onUpdate=new Pt("update"),this.onError=new Pt("onError")}bind(t){this.onResize.add(t),this.onUpdate.add(t),this.onError.add(t),(this._width||this._height)&&this.onResize.emit(this._width,this._height)}unbind(t){this.onResize.remove(t),this.onUpdate.remove(t),this.onError.remove(t)}resize(t,e){(t!==this._width||e!==this._height)&&(this._width=t,this._height=e,this.onResize.emit(t,e))}get valid(){return!!this._width&&!!this._height}update(){this.destroyed||this.onUpdate.emit()}load(){return Promise.resolve(this)}get width(){return this._width}get height(){return this._height}style(t,e,s){return!1}dispose(){}destroy(){this.destroyed||(this.destroyed=!0,this.dispose(),this.onError.removeAll(),this.onError=null,this.onResize.removeAll(),this.onResize=null,this.onUpdate.removeAll(),this.onUpdate=null)}static test(t,e){return!1}}class xs extends Qe{constructor(t,e){var s;const{width:r,height:n}=e||{};if(!r||!n)throw new Error("BufferResource width or height invalid");super(r,n),this.data=t,this.unpackAlignment=(s=e.unpackAlignment)!=null?s:4}upload(t,e,s){const r=t.gl;r.pixelStorei(r.UNPACK_ALIGNMENT,this.unpackAlignment),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===At.UNPACK);const n=e.realWidth,a=e.realHeight;return s.width===n&&s.height===a?r.texSubImage2D(e.target,0,0,0,n,a,e.format,s.type,this.data):(s.width=n,s.height=a,r.texImage2D(e.target,0,s.internalFormat,n,a,0,e.format,s.type,this.data)),!0}dispose(){this.data=null}static test(t){return t===null||t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array}}var hd=Object.defineProperty,No=Object.getOwnPropertySymbols,ld=Object.prototype.hasOwnProperty,ud=Object.prototype.propertyIsEnumerable,Lo=(i,t,e)=>t in i?hd(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,cd=(i,t)=>{for(var e in t||(t={}))ld.call(t,e)&&Lo(i,e,t[e]);if(No)for(var e of No(t))ud.call(t,e)&&Lo(i,e,t[e]);return i};const dd={scaleMode:Bt.NEAREST,alphaMode:At.NPM},en=class ns extends Ye{constructor(t=null,e=null){super(),e=Object.assign({},ns.defaultOptions,e);const{alphaMode:s,mipmap:r,anisotropicLevel:n,scaleMode:a,width:o,height:h,wrapMode:l,format:u,type:c,target:d,resolution:f,resourceOptions:p}=e;t&&!(t instanceof Qe)&&(t=tn(t,p),t.internal=!0),this.resolution=f||N.RESOLUTION,this.width=Math.round((o||0)*this.resolution)/this.resolution,this.height=Math.round((h||0)*this.resolution)/this.resolution,this._mipmap=r,this.anisotropicLevel=n,this._wrapMode=l,this._scaleMode=a,this.format=u,this.type=c,this.target=d,this.alphaMode=s,this.uid=Te(),this.touched=0,this.isPowerOfTwo=!1,this._refreshPOT(),this._glTextures={},this.dirtyId=0,this.dirtyStyleId=0,this.cacheId=null,this.valid=o>0&&h>0,this.textureCacheIds=[],this.destroyed=!1,this.resource=null,this._batchEnabled=0,this._batchLocation=0,this.parentTextureArray=null,this.setResource(t)}get realWidth(){return Math.round(this.width*this.resolution)}get realHeight(){return Math.round(this.height*this.resolution)}get mipmap(){return this._mipmap}set mipmap(t){this._mipmap!==t&&(this._mipmap=t,this.dirtyStyleId++)}get scaleMode(){return this._scaleMode}set scaleMode(t){this._scaleMode!==t&&(this._scaleMode=t,this.dirtyStyleId++)}get wrapMode(){return this._wrapMode}set wrapMode(t){this._wrapMode!==t&&(this._wrapMode=t,this.dirtyStyleId++)}setStyle(t,e){let s;return t!==void 0&&t!==this.scaleMode&&(this.scaleMode=t,s=!0),e!==void 0&&e!==this.mipmap&&(this.mipmap=e,s=!0),s&&this.dirtyStyleId++,this}setSize(t,e,s){return s=s||this.resolution,this.setRealSize(t*s,e*s,s)}setRealSize(t,e,s){return this.resolution=s||this.resolution,this.width=Math.round(t)/this.resolution,this.height=Math.round(e)/this.resolution,this._refreshPOT(),this.update(),this}_refreshPOT(){this.isPowerOfTwo=Hr(this.realWidth)&&Hr(this.realHeight)}setResolution(t){const e=this.resolution;return e===t?this:(this.resolution=t,this.valid&&(this.width=Math.round(this.width*e)/t,this.height=Math.round(this.height*e)/t,this.emit("update",this)),this._refreshPOT(),this)}setResource(t){if(this.resource===t)return this;if(this.resource)throw new Error("Resource can be set only once");return t.bind(this),this.resource=t,this}update(){this.valid?(this.dirtyId++,this.dirtyStyleId++,this.emit("update",this)):this.width>0&&this.height>0&&(this.valid=!0,this.emit("loaded",this),this.emit("update",this))}onError(t){this.emit("error",this,t)}destroy(){this.resource&&(this.resource.unbind(this),this.resource.internal&&this.resource.destroy(),this.resource=null),this.cacheId&&(delete It[this.cacheId],delete wt[this.cacheId],this.cacheId=null),this.valid=!1,this.dispose(),ns.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0,this.emit("destroyed",this),this.removeAllListeners()}dispose(){this.emit("dispose",this)}castToBaseTexture(){return this}static from(t,e,s=N.STRICT_TEXTURE_CACHE){const r=typeof t=="string";let n=null;if(r)n=t;else{if(!t._pixiId){const o=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t._pixiId=`${o}_${Te()}`}n=t._pixiId}let a=It[n];if(r&&s&&!a)throw new Error(`The cacheId "${n}" does not exist in BaseTextureCache.`);return a||(a=new ns(t,e),a.cacheId=n,ns.addToCache(a,n)),a}static fromBuffer(t,e,s,r){t=t||new Float32Array(e*s*4);const n=new xs(t,cd({width:e,height:s},r==null?void 0:r.resourceOptions));let a,o;return t instanceof Float32Array?(a=M.RGBA,o=$.FLOAT):t instanceof Int32Array?(a=M.RGBA_INTEGER,o=$.INT):t instanceof Uint32Array?(a=M.RGBA_INTEGER,o=$.UNSIGNED_INT):t instanceof Int16Array?(a=M.RGBA_INTEGER,o=$.SHORT):t instanceof Uint16Array?(a=M.RGBA_INTEGER,o=$.UNSIGNED_SHORT):t instanceof Int8Array?(a=M.RGBA,o=$.BYTE):(a=M.RGBA,o=$.UNSIGNED_BYTE),n.internal=!0,new ns(n,Object.assign({},dd,{type:o,format:a},r))}static addToCache(t,e){e&&(t.textureCacheIds.includes(e)||t.textureCacheIds.push(e),It[e]&&It[e]!==t&&console.warn(`BaseTexture added to the cache with an id [${e}] that already had an entry`),It[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=It[t];if(e){const s=e.textureCacheIds.indexOf(t);return s>-1&&e.textureCacheIds.splice(s,1),delete It[t],e}}else if(t!=null&&t.textureCacheIds){for(let e=0;e1){for(let c=0;c(i[i.POLY=0]="POLY",i[i.RECT=1]="RECT",i[i.CIRC=2]="CIRC",i[i.ELIP=3]="ELIP",i[i.RREC=4]="RREC",i))(it||{});class K{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new K(this.x,this.y)}copyFrom(t){return this.set(t.x,t.y),this}copyTo(t){return t.set(this.x,this.y),t}equals(t){return t.x===this.x&&t.y===this.y}set(t=0,e=t){return this.x=t,this.y=e,this}}const wi=[new K,new K,new K,new K];class z{constructor(t=0,e=0,s=0,r=0){this.x=Number(t),this.y=Number(e),this.width=Number(s),this.height=Number(r),this.type=it.RECT}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}static get EMPTY(){return new z(0,0,0,0)}clone(){return new z(this.x,this.y,this.width,this.height)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}contains(t,e){return this.width<=0||this.height<=0?!1:t>=this.x&&t=this.y&&et.right?t.right:this.right)<=A)return!1;const S=this.yt.bottom?t.bottom:this.bottom)>S}const s=this.left,r=this.right,n=this.top,a=this.bottom;if(r<=s||a<=n)return!1;const o=wi[0].set(t.left,t.top),h=wi[1].set(t.left,t.bottom),l=wi[2].set(t.right,t.top),u=wi[3].set(t.right,t.bottom);if(l.x<=o.x||h.y<=o.y)return!1;const c=Math.sign(e.a*e.d-e.b*e.c);if(c===0||(e.apply(o,o),e.apply(h,h),e.apply(l,l),e.apply(u,u),Math.max(o.x,h.x,l.x,u.x)<=s||Math.min(o.x,h.x,l.x,u.x)>=r||Math.max(o.y,h.y,l.y,u.y)<=n||Math.min(o.y,h.y,l.y,u.y)>=a))return!1;const d=c*(h.y-o.y),f=c*(o.x-h.x),p=d*s+f*n,m=d*r+f*n,g=d*s+f*a,_=d*r+f*a;if(Math.max(p,m,g,_)<=d*o.x+f*o.y||Math.min(p,m,g,_)>=d*u.x+f*u.y)return!1;const x=c*(o.y-l.y),v=c*(l.x-o.x),b=x*s+v*n,T=x*r+v*n,R=x*s+v*a,w=x*r+v*a;return!(Math.max(b,T,R,w)<=x*o.x+v*o.y||Math.min(b,T,R,w)>=x*u.x+v*u.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2,this}fit(t){const e=Math.max(this.x,t.x),s=Math.min(this.x+this.width,t.x+t.width),r=Math.max(this.y,t.y),n=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(s-e,0),this.y=r,this.height=Math.max(n-r,0),this}ceil(t=1,e=.001){const s=Math.ceil((this.x+this.width-e)*t)/t,r=Math.ceil((this.y+this.height-e)*t)/t;return this.x=Math.floor((this.x+e)*t)/t,this.y=Math.floor((this.y+e)*t)/t,this.width=s-this.x,this.height=r-this.y,this}enlarge(t){const e=Math.min(this.x,t.x),s=Math.max(this.x+this.width,t.x+t.width),r=Math.min(this.y,t.y),n=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=s-e,this.y=r,this.height=n-r,this}}class Si{constructor(t=0,e=0,s=0){this.x=t,this.y=e,this.radius=s,this.type=it.CIRC}clone(){return new Si(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const s=this.radius*this.radius;let r=this.x-t,n=this.y-e;return r*=r,n*=n,r+n<=s}getBounds(){return new z(this.x-this.radius,this.y-this.radius,this.radius*2,this.radius*2)}}class Ci{constructor(t=0,e=0,s=0,r=0){this.x=t,this.y=e,this.width=s,this.height=r,this.type=it.ELIP}clone(){return new Ci(this.x,this.y,this.width,this.height)}contains(t,e){if(this.width<=0||this.height<=0)return!1;let s=(t-this.x)/this.width,r=(e-this.y)/this.height;return s*=s,r*=r,s+r<=1}getBounds(){return new z(this.x-this.width,this.y-this.height,this.width,this.height)}}class Be{constructor(...t){let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const s=[];for(let r=0,n=e.length;re!=u>e&&t<(l-o)*((e-h)/(u-h))+o&&(s=!s)}return s}}class Ri{constructor(t=0,e=0,s=0,r=0,n=20){this.x=t,this.y=e,this.width=s,this.height=r,this.radius=n,this.type=it.RREC}clone(){return new Ri(this.x,this.y,this.width,this.height,this.radius)}contains(t,e){if(this.width<=0||this.height<=0)return!1;if(t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height){const s=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+s&&e<=this.y+this.height-s||t>=this.x+s&&t<=this.x+this.width-s)return!0;let r=t-(this.x+s),n=e-(this.y+s);const a=s*s;if(r*r+n*n<=a||(r=t-(this.x+this.width-s),r*r+n*n<=a)||(n=e-(this.y+this.height-s),r*r+n*n<=a)||(r=t-(this.x+s),r*r+n*n<=a))return!0}return!1}}class tt{constructor(t=1,e=0,s=0,r=1,n=0,a=0){this.array=null,this.a=t,this.b=e,this.c=s,this.d=r,this.tx=n,this.ty=a}fromArray(t){this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]}set(t,e,s,r,n,a){return this.a=t,this.b=e,this.c=s,this.d=r,this.tx=n,this.ty=a,this}toArray(t,e){this.array||(this.array=new Float32Array(9));const s=e||this.array;return t?(s[0]=this.a,s[1]=this.b,s[2]=0,s[3]=this.c,s[4]=this.d,s[5]=0,s[6]=this.tx,s[7]=this.ty,s[8]=1):(s[0]=this.a,s[1]=this.c,s[2]=this.tx,s[3]=this.b,s[4]=this.d,s[5]=this.ty,s[6]=0,s[7]=0,s[8]=1),s}apply(t,e){e=e||new K;const s=t.x,r=t.y;return e.x=this.a*s+this.c*r+this.tx,e.y=this.b*s+this.d*r+this.ty,e}applyInverse(t,e){e=e||new K;const s=1/(this.a*this.d+this.c*-this.b),r=t.x,n=t.y;return e.x=this.d*s*r+-this.c*s*n+(this.ty*this.c-this.tx*this.d)*s,e.y=this.a*s*n+-this.b*s*r+(-this.ty*this.a+this.tx*this.b)*s,e}translate(t,e){return this.tx+=t,this.ty+=e,this}scale(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this}rotate(t){const e=Math.cos(t),s=Math.sin(t),r=this.a,n=this.c,a=this.tx;return this.a=r*e-this.b*s,this.b=r*s+this.b*e,this.c=n*e-this.d*s,this.d=n*s+this.d*e,this.tx=a*e-this.ty*s,this.ty=a*s+this.ty*e,this}append(t){const e=this.a,s=this.b,r=this.c,n=this.d;return this.a=t.a*e+t.b*r,this.b=t.a*s+t.b*n,this.c=t.c*e+t.d*r,this.d=t.c*s+t.d*n,this.tx=t.tx*e+t.ty*r+this.tx,this.ty=t.tx*s+t.ty*n+this.ty,this}setTransform(t,e,s,r,n,a,o,h,l){return this.a=Math.cos(o+l)*n,this.b=Math.sin(o+l)*n,this.c=-Math.sin(o-h)*a,this.d=Math.cos(o-h)*a,this.tx=t-(s*this.a+r*this.c),this.ty=e-(s*this.b+r*this.d),this}prepend(t){const e=this.tx;if(t.a!==1||t.b!==0||t.c!==0||t.d!==1){const s=this.a,r=this.c;this.a=s*t.a+this.b*t.c,this.b=s*t.b+this.b*t.d,this.c=r*t.a+this.d*t.c,this.d=r*t.b+this.d*t.d}return this.tx=e*t.a+this.ty*t.c+t.tx,this.ty=e*t.b+this.ty*t.d+t.ty,this}decompose(t){const e=this.a,s=this.b,r=this.c,n=this.d,a=t.pivot,o=-Math.atan2(-r,n),h=Math.atan2(s,e),l=Math.abs(o+h);return l<1e-5||Math.abs(Ts-l)<1e-5?(t.rotation=h,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=o,t.skew.y=h),t.scale.x=Math.sqrt(e*e+s*s),t.scale.y=Math.sqrt(r*r+n*n),t.position.x=this.tx+(a.x*e+a.y*r),t.position.y=this.ty+(a.x*s+a.y*n),t}invert(){const t=this.a,e=this.b,s=this.c,r=this.d,n=this.tx,a=t*r-e*s;return this.a=r/a,this.b=-e/a,this.c=-s/a,this.d=t/a,this.tx=(s*this.ty-r*n)/a,this.ty=-(t*this.ty-e*n)/a,this}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const t=new tt;return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyTo(t){return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyFrom(t){return this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.tx=t.tx,this.ty=t.ty,this}static get IDENTITY(){return new tt}static get TEMP_MATRIX(){return new tt}}const Fe=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],Ne=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],Le=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],Ue=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],rn=[],$o=[],Ii=Math.sign;function vd(){for(let i=0;i<16;i++){const t=[];rn.push(t);for(let e=0;e<16;e++){const s=Ii(Fe[i]*Fe[e]+Le[i]*Ne[e]),r=Ii(Ne[i]*Fe[e]+Ue[i]*Ne[e]),n=Ii(Fe[i]*Le[e]+Le[i]*Ue[e]),a=Ii(Ne[i]*Le[e]+Ue[i]*Ue[e]);for(let o=0;o<16;o++)if(Fe[o]===s&&Ne[o]===r&&Le[o]===n&&Ue[o]===a){t.push(o);break}}}for(let i=0;i<16;i++){const t=new tt;t.set(Fe[i],Ne[i],Le[i],Ue[i],0,0),$o.push(t)}}vd();const at={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:i=>Fe[i],uY:i=>Ne[i],vX:i=>Le[i],vY:i=>Ue[i],inv:i=>i&8?i&15:-i&7,add:(i,t)=>rn[i][t],sub:(i,t)=>rn[i][at.inv(t)],rotate180:i=>i^4,isVertical:i=>(i&3)===2,byDirection:(i,t)=>Math.abs(i)*2<=Math.abs(t)?t>=0?at.S:at.N:Math.abs(t)*2<=Math.abs(i)?i>0?at.E:at.W:t>0?i>0?at.SE:at.SW:i>0?at.NE:at.NW,matrixAppendRotationInv:(i,t,e=0,s=0)=>{const r=$o[at.inv(t)];r.tx=e,r.ty=s,i.append(r)}};class de{constructor(t,e,s=0,r=0){this._x=s,this._y=r,this.cb=t,this.scope=e}clone(t=this.cb,e=this.scope){return new de(t,e,this._x,this._y)}set(t=0,e=t){return(this._x!==t||this._y!==e)&&(this._x=t,this._y=e,this.cb.call(this.scope)),this}copyFrom(t){return(this._x!==t.x||this._y!==t.y)&&(this._x=t.x,this._y=t.y,this.cb.call(this.scope)),this}copyTo(t){return t.set(this._x,this._y),t}equals(t){return t.x===this._x&&t.y===this._y}get x(){return this._x}set x(t){this._x!==t&&(this._x=t,this.cb.call(this.scope))}get y(){return this._y}set y(t){this._y!==t&&(this._y=t,this.cb.call(this.scope))}}const nn=class{constructor(){this.worldTransform=new tt,this.localTransform=new tt,this.position=new de(this.onChange,this,0,0),this.scale=new de(this.onChange,this,1,1),this.pivot=new de(this.onChange,this,0,0),this.skew=new de(this.updateSkew,this,0,0),this._rotation=0,this._cx=1,this._sx=0,this._cy=0,this._sy=1,this._localID=0,this._currentLocalID=0,this._worldID=0,this._parentID=0}onChange(){this._localID++}updateSkew(){this._cx=Math.cos(this._rotation+this.skew.y),this._sx=Math.sin(this._rotation+this.skew.y),this._cy=-Math.sin(this._rotation-this.skew.x),this._sy=Math.cos(this._rotation-this.skew.x),this._localID++}updateLocalTransform(){const t=this.localTransform;this._localID!==this._currentLocalID&&(t.a=this._cx*this.scale.x,t.b=this._sx*this.scale.x,t.c=this._cy*this.scale.y,t.d=this._sy*this.scale.y,t.tx=this.position.x-(this.pivot.x*t.a+this.pivot.y*t.c),t.ty=this.position.y-(this.pivot.x*t.b+this.pivot.y*t.d),this._currentLocalID=this._localID,this._parentID=-1)}updateTransform(t){const e=this.localTransform;if(this._localID!==this._currentLocalID&&(e.a=this._cx*this.scale.x,e.b=this._sx*this.scale.x,e.c=this._cy*this.scale.y,e.d=this._sy*this.scale.y,e.tx=this.position.x-(this.pivot.x*e.a+this.pivot.y*e.c),e.ty=this.position.y-(this.pivot.x*e.b+this.pivot.y*e.d),this._currentLocalID=this._localID,this._parentID=-1),this._parentID!==t._worldID){const s=t.worldTransform,r=this.worldTransform;r.a=e.a*s.a+e.b*s.c,r.b=e.a*s.b+e.b*s.d,r.c=e.c*s.a+e.d*s.c,r.d=e.c*s.b+e.d*s.d,r.tx=e.tx*s.a+e.ty*s.c+s.tx,r.ty=e.tx*s.b+e.ty*s.d+s.ty,this._parentID=t._worldID,this._worldID++}}setFromMatrix(t){t.decompose(this),this._localID++}get rotation(){return this._rotation}set rotation(t){this._rotation!==t&&(this._rotation=t,this.updateSkew())}};nn.IDENTITY=new nn;let Pi=nn;var yd=`varying vec2 vTextureCoord; + +uniform sampler2D uSampler; + +void main(void){ + gl_FragColor *= texture2D(uSampler, vTextureCoord); +}`,xd=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void){ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +} +`;function Ho(i,t,e){const s=i.createShader(t);return i.shaderSource(s,e),i.compileShader(s),s}function an(i){const t=new Array(i);for(let e=0;ei.type==="float"&&i.size===1&&!i.isArray,code:i=>` + if(uv["${i}"] !== ud["${i}"].value) + { + ud["${i}"].value = uv["${i}"] + gl.uniform1f(ud["${i}"].location, uv["${i}"]) + } + `},{test:(i,t)=>(i.type==="sampler2D"||i.type==="samplerCube"||i.type==="sampler2DArray")&&i.size===1&&!i.isArray&&(t==null||t.castToBaseTexture!==void 0),code:i=>`t = syncData.textureCount++; + + renderer.texture.bind(uv["${i}"], t); + + if(ud["${i}"].value !== t) + { + ud["${i}"].value = t; + gl.uniform1i(ud["${i}"].location, t); +; // eslint-disable-line max-len + }`},{test:(i,t)=>i.type==="mat3"&&i.size===1&&!i.isArray&&t.a!==void 0,code:i=>` + gl.uniformMatrix3fv(ud["${i}"].location, false, uv["${i}"].toArray(true)); + `,codeUbo:i=>` + var ${i}_matrix = uv.${i}.toArray(true); + + data[offset] = ${i}_matrix[0]; + data[offset+1] = ${i}_matrix[1]; + data[offset+2] = ${i}_matrix[2]; + + data[offset + 4] = ${i}_matrix[3]; + data[offset + 5] = ${i}_matrix[4]; + data[offset + 6] = ${i}_matrix[5]; + + data[offset + 8] = ${i}_matrix[6]; + data[offset + 9] = ${i}_matrix[7]; + data[offset + 10] = ${i}_matrix[8]; + `},{test:(i,t)=>i.type==="vec2"&&i.size===1&&!i.isArray&&t.x!==void 0,code:i=>` + cv = ud["${i}"].value; + v = uv["${i}"]; + + if(cv[0] !== v.x || cv[1] !== v.y) + { + cv[0] = v.x; + cv[1] = v.y; + gl.uniform2f(ud["${i}"].location, v.x, v.y); + }`,codeUbo:i=>` + v = uv.${i}; + + data[offset] = v.x; + data[offset+1] = v.y; + `},{test:i=>i.type==="vec2"&&i.size===1&&!i.isArray,code:i=>` + cv = ud["${i}"].value; + v = uv["${i}"]; + + if(cv[0] !== v[0] || cv[1] !== v[1]) + { + cv[0] = v[0]; + cv[1] = v[1]; + gl.uniform2f(ud["${i}"].location, v[0], v[1]); + } + `},{test:(i,t)=>i.type==="vec4"&&i.size===1&&!i.isArray&&t.width!==void 0,code:i=>` + cv = ud["${i}"].value; + v = uv["${i}"]; + + if(cv[0] !== v.x || cv[1] !== v.y || cv[2] !== v.width || cv[3] !== v.height) + { + cv[0] = v.x; + cv[1] = v.y; + cv[2] = v.width; + cv[3] = v.height; + gl.uniform4f(ud["${i}"].location, v.x, v.y, v.width, v.height) + }`,codeUbo:i=>` + v = uv.${i}; + + data[offset] = v.x; + data[offset+1] = v.y; + data[offset+2] = v.width; + data[offset+3] = v.height; + `},{test:(i,t)=>i.type==="vec4"&&i.size===1&&!i.isArray&&t.red!==void 0,code:i=>` + cv = ud["${i}"].value; + v = uv["${i}"]; + + if(cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.alpha) + { + cv[0] = v.red; + cv[1] = v.green; + cv[2] = v.blue; + cv[3] = v.alpha; + gl.uniform4f(ud["${i}"].location, v.red, v.green, v.blue, v.alpha) + }`,codeUbo:i=>` + v = uv.${i}; + + data[offset] = v.red; + data[offset+1] = v.green; + data[offset+2] = v.blue; + data[offset+3] = v.alpha; + `},{test:(i,t)=>i.type==="vec3"&&i.size===1&&!i.isArray&&t.red!==void 0,code:i=>` + cv = ud["${i}"].value; + v = uv["${i}"]; + + if(cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.a) + { + cv[0] = v.red; + cv[1] = v.green; + cv[2] = v.blue; + + gl.uniform3f(ud["${i}"].location, v.red, v.green, v.blue) + }`,codeUbo:i=>` + v = uv.${i}; + + data[offset] = v.red; + data[offset+1] = v.green; + data[offset+2] = v.blue; + `},{test:i=>i.type==="vec4"&&i.size===1&&!i.isArray,code:i=>` + cv = ud["${i}"].value; + v = uv["${i}"]; + + if(cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) + { + cv[0] = v[0]; + cv[1] = v[1]; + cv[2] = v[2]; + cv[3] = v[3]; + + gl.uniform4f(ud["${i}"].location, v[0], v[1], v[2], v[3]) + }`}],bd={float:` + if (cv !== v) + { + cu.value = v; + gl.uniform1f(location, v); + }`,vec2:` + if (cv[0] !== v[0] || cv[1] !== v[1]) + { + cv[0] = v[0]; + cv[1] = v[1]; + + gl.uniform2f(location, v[0], v[1]) + }`,vec3:` + if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) + { + cv[0] = v[0]; + cv[1] = v[1]; + cv[2] = v[2]; + + gl.uniform3f(location, v[0], v[1], v[2]) + }`,vec4:` + if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) + { + cv[0] = v[0]; + cv[1] = v[1]; + cv[2] = v[2]; + cv[3] = v[3]; + + gl.uniform4f(location, v[0], v[1], v[2], v[3]); + }`,int:` + if (cv !== v) + { + cu.value = v; + + gl.uniform1i(location, v); + }`,ivec2:` + if (cv[0] !== v[0] || cv[1] !== v[1]) + { + cv[0] = v[0]; + cv[1] = v[1]; + + gl.uniform2i(location, v[0], v[1]); + }`,ivec3:` + if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) + { + cv[0] = v[0]; + cv[1] = v[1]; + cv[2] = v[2]; + + gl.uniform3i(location, v[0], v[1], v[2]); + }`,ivec4:` + if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) + { + cv[0] = v[0]; + cv[1] = v[1]; + cv[2] = v[2]; + cv[3] = v[3]; + + gl.uniform4i(location, v[0], v[1], v[2], v[3]); + }`,uint:` + if (cv !== v) + { + cu.value = v; + + gl.uniform1ui(location, v); + }`,uvec2:` + if (cv[0] !== v[0] || cv[1] !== v[1]) + { + cv[0] = v[0]; + cv[1] = v[1]; + + gl.uniform2ui(location, v[0], v[1]); + }`,uvec3:` + if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) + { + cv[0] = v[0]; + cv[1] = v[1]; + cv[2] = v[2]; + + gl.uniform3ui(location, v[0], v[1], v[2]); + }`,uvec4:` + if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) + { + cv[0] = v[0]; + cv[1] = v[1]; + cv[2] = v[2]; + cv[3] = v[3]; + + gl.uniform4ui(location, v[0], v[1], v[2], v[3]); + }`,bool:` + if (cv !== v) + { + cu.value = v; + gl.uniform1i(location, v); + }`,bvec2:` + if (cv[0] != v[0] || cv[1] != v[1]) + { + cv[0] = v[0]; + cv[1] = v[1]; + + gl.uniform2i(location, v[0], v[1]); + }`,bvec3:` + if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) + { + cv[0] = v[0]; + cv[1] = v[1]; + cv[2] = v[2]; + + gl.uniform3i(location, v[0], v[1], v[2]); + }`,bvec4:` + if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) + { + cv[0] = v[0]; + cv[1] = v[1]; + cv[2] = v[2]; + cv[3] = v[3]; + + gl.uniform4i(location, v[0], v[1], v[2], v[3]); + }`,mat2:"gl.uniformMatrix2fv(location, false, v)",mat3:"gl.uniformMatrix3fv(location, false, v)",mat4:"gl.uniformMatrix4fv(location, false, v)",sampler2D:` + if (cv !== v) + { + cu.value = v; + + gl.uniform1i(location, v); + }`,samplerCube:` + if (cv !== v) + { + cu.value = v; + + gl.uniform1i(location, v); + }`,sampler2DArray:` + if (cv !== v) + { + cu.value = v; + + gl.uniform1i(location, v); + }`},Td={float:"gl.uniform1fv(location, v)",vec2:"gl.uniform2fv(location, v)",vec3:"gl.uniform3fv(location, v)",vec4:"gl.uniform4fv(location, v)",mat4:"gl.uniformMatrix4fv(location, false, v)",mat3:"gl.uniformMatrix3fv(location, false, v)",mat2:"gl.uniformMatrix2fv(location, false, v)",int:"gl.uniform1iv(location, v)",ivec2:"gl.uniform2iv(location, v)",ivec3:"gl.uniform3iv(location, v)",ivec4:"gl.uniform4iv(location, v)",uint:"gl.uniform1uiv(location, v)",uvec2:"gl.uniform2uiv(location, v)",uvec3:"gl.uniform3uiv(location, v)",uvec4:"gl.uniform4uiv(location, v)",bool:"gl.uniform1iv(location, v)",bvec2:"gl.uniform2iv(location, v)",bvec3:"gl.uniform3iv(location, v)",bvec4:"gl.uniform4iv(location, v)",sampler2D:"gl.uniform1iv(location, v)",samplerCube:"gl.uniform1iv(location, v)",sampler2DArray:"gl.uniform1iv(location, v)"};function Ed(i,t){var e;const s=[` + var v = null; + var cv = null; + var cu = null; + var t = 0; + var gl = renderer.gl; + `];for(const r in i.uniforms){const n=t[r];if(!n){((e=i.uniforms[r])==null?void 0:e.group)===!0&&(i.uniforms[r].ubo?s.push(` + renderer.shader.syncUniformBufferGroup(uv.${r}, '${r}'); + `):s.push(` + renderer.shader.syncUniformGroup(uv.${r}, syncData); + `));continue}const a=i.uniforms[r];let o=!1;for(let h=0;h=be.WEBGL2&&(t=i.getContext("webgl2",{})),t||(t=i.getContext("webgl",{})||i.getContext("experimental-webgl",{}),t?t.getExtension("WEBGL_draw_buffers"):t=null),Es=t}return Es}let Mi;function Ad(){if(!Mi){Mi=Rt.MEDIUM;const i=Xo();i&&i.getShaderPrecisionFormat&&(Mi=i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision?Rt.HIGH:Rt.MEDIUM)}return Mi}function zo(i,t){const e=i.getShaderSource(t).split(` +`).map((l,u)=>`${u}: ${l}`),s=i.getShaderInfoLog(t),r=s.split(` +`),n={},a=r.map(l=>parseFloat(l.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))).filter(l=>l&&!n[l]?(n[l]=!0,!0):!1),o=[""];a.forEach(l=>{e[l-1]=`%c${e[l-1]}%c`,o.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")});const h=e.join(` +`);o[0]=h,console.error(s),console.groupCollapsed("click to view full shader code"),console.warn(...o),console.groupEnd()}function wd(i,t,e,s){i.getProgramParameter(t,i.LINK_STATUS)||(i.getShaderParameter(e,i.COMPILE_STATUS)||zo(i,e),i.getShaderParameter(s,i.COMPILE_STATUS)||zo(i,s),console.error("PixiJS Error: Could not initialize shader."),i.getProgramInfoLog(t)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",i.getProgramInfoLog(t)))}const Sd={float:1,vec2:2,vec3:3,vec4:4,int:1,ivec2:2,ivec3:3,ivec4:4,uint:1,uvec2:2,uvec3:3,uvec4:4,bool:1,bvec2:2,bvec3:3,bvec4:4,mat2:4,mat3:9,mat4:16,sampler2D:1};function Wo(i){return Sd[i]}let Di=null;const Yo={FLOAT:"float",FLOAT_VEC2:"vec2",FLOAT_VEC3:"vec3",FLOAT_VEC4:"vec4",INT:"int",INT_VEC2:"ivec2",INT_VEC3:"ivec3",INT_VEC4:"ivec4",UNSIGNED_INT:"uint",UNSIGNED_INT_VEC2:"uvec2",UNSIGNED_INT_VEC3:"uvec3",UNSIGNED_INT_VEC4:"uvec4",BOOL:"bool",BOOL_VEC2:"bvec2",BOOL_VEC3:"bvec3",BOOL_VEC4:"bvec4",FLOAT_MAT2:"mat2",FLOAT_MAT3:"mat3",FLOAT_MAT4:"mat4",SAMPLER_2D:"sampler2D",INT_SAMPLER_2D:"sampler2D",UNSIGNED_INT_SAMPLER_2D:"sampler2D",SAMPLER_CUBE:"samplerCube",INT_SAMPLER_CUBE:"samplerCube",UNSIGNED_INT_SAMPLER_CUBE:"samplerCube",SAMPLER_2D_ARRAY:"sampler2DArray",INT_SAMPLER_2D_ARRAY:"sampler2DArray",UNSIGNED_INT_SAMPLER_2D_ARRAY:"sampler2DArray"};function qo(i,t){if(!Di){const e=Object.keys(Yo);Di={};for(let s=0;s0&&(e+=` +else `),sthis.size&&this.flush(),this._vertexCount+=t.vertexData.length/2,this._indexCount+=t.indices.length,this._bufferedTextures[this._bufferSize]=t._texture.baseTexture,this._bufferedElements[this._bufferSize++]=t)}buildTexturesAndDrawCalls(){const{_bufferedTextures:t,maxTextures:e}=this,s=Kt._textureArrayPool,r=this.renderer.batch,n=this._tempBoundTextures,a=this.renderer.textureGC.count;let o=++X._globalBatch,h=0,l=s[0],u=0;r.copyBoundTextures(n,e);for(let c=0;c=e&&(r.boundArray(l,n,o,e),this.buildDrawCalls(l,u,c),u=c,l=s[++h],++o),d._batchEnabled=o,d.touched=a,l.elements[l.count++]=d)}l.count>0&&(r.boundArray(l,n,o,e),this.buildDrawCalls(l,u,this._bufferSize),++h,++o);for(let c=0;c0);for(let m=0;m=0;--r)t[r]=s[r]||null,t[r]&&(t[r]._batchLocation=r)}boundArray(t,e,s,r){const{elements:n,ids:a,count:o}=t;let h=0;for(let l=0;l=0&&c=be.WEBGL2&&(s=t.getContext("webgl2",e)),s)this.webGLVersion=2;else if(this.webGLVersion=1,s=t.getContext("webgl",e)||t.getContext("experimental-webgl",e),!s)throw new Error("This browser does not support WebGL. Try using the canvas renderer");return this.gl=s,this.getExtensions(),this.gl}getExtensions(){const{gl:t}=this,e={loseContext:t.getExtension("WEBGL_lose_context"),anisotropicFiltering:t.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),s3tc:t.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:t.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:t.getExtension("WEBGL_compressed_texture_etc"),etc1:t.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:t.getExtension("WEBGL_compressed_texture_atc"),astc:t.getExtension("WEBGL_compressed_texture_astc")};this.webGLVersion===1?Object.assign(this.extensions,e,{drawBuffers:t.getExtension("WEBGL_draw_buffers"),depthTexture:t.getExtension("WEBGL_depth_texture"),vertexArrayObject:t.getExtension("OES_vertex_array_object")||t.getExtension("MOZ_OES_vertex_array_object")||t.getExtension("WEBKIT_OES_vertex_array_object"),uint32ElementIndex:t.getExtension("OES_element_index_uint"),floatTexture:t.getExtension("OES_texture_float"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),textureHalfFloat:t.getExtension("OES_texture_half_float"),textureHalfFloatLinear:t.getExtension("OES_texture_half_float_linear")}):this.webGLVersion===2&&Object.assign(this.extensions,e,{colorBufferFloat:t.getExtension("EXT_color_buffer_float")})}handleContextLost(t){t.preventDefault(),setTimeout(()=>{this.gl.isContextLost()&&this.extensions.loseContext&&this.extensions.loseContext.restoreContext()},0)}handleContextRestored(){this.renderer.runners.contextChange.emit(this.gl)}destroy(){const t=this.renderer.view;this.renderer=null,t.removeEventListener!==void 0&&(t.removeEventListener("webglcontextlost",this.handleContextLost),t.removeEventListener("webglcontextrestored",this.handleContextRestored)),this.gl.useProgram(null),this.extensions.loseContext&&this.extensions.loseContext.loseContext()}postrender(){this.renderer.objectRenderer.renderingToScreen&&this.gl.flush()}validateContext(t){const e=t.getContextAttributes(),s="WebGL2RenderingContext"in globalThis&&t instanceof globalThis.WebGL2RenderingContext;s&&(this.webGLVersion=2),e&&!e.stencil&&console.warn("Provided WebGL context does not have a stencil buffer, masks may not render correctly");const r=s||!!t.getExtension("OES_element_index_uint");this.supports.uint32Indices=r,r||console.warn("Provided WebGL context does not support 32 index buffer, complex graphics may not render correctly")}}Rs.defaultOptions={context:null,antialias:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:"default"},Rs.extension={type:D.RendererSystem,name:"context"},U.add(Rs);class Fi{constructor(t,e){if(this.width=Math.round(t),this.height=Math.round(e),!this.width||!this.height)throw new Error("Framebuffer width or height is zero");this.stencil=!1,this.depth=!1,this.dirtyId=0,this.dirtyFormat=0,this.dirtySize=0,this.depthTexture=null,this.colorTextures=[],this.glFramebuffers={},this.disposeRunner=new Pt("disposeFramebuffer"),this.multisample=ft.NONE}get colorTexture(){return this.colorTextures[0]}addColorTexture(t=0,e){return this.colorTextures[t]=e||new X(null,{scaleMode:Bt.NEAREST,resolution:1,mipmap:Ht.OFF,width:this.width,height:this.height}),this.dirtyId++,this.dirtyFormat++,this}addDepthTexture(t){return this.depthTexture=t||new X(null,{scaleMode:Bt.NEAREST,resolution:1,width:this.width,height:this.height,mipmap:Ht.OFF,format:M.DEPTH_COMPONENT,type:$.UNSIGNED_SHORT}),this.dirtyId++,this.dirtyFormat++,this}enableDepth(){return this.depth=!0,this.dirtyId++,this.dirtyFormat++,this}enableStencil(){return this.stencil=!0,this.dirtyId++,this.dirtyFormat++,this}resize(t,e){if(t=Math.round(t),e=Math.round(e),!t||!e)throw new Error("Framebuffer width and height must not be zero");if(!(t===this.width&&e===this.height)){this.width=t,this.height=e,this.dirtyId++,this.dirtySize++;for(let s=0;s{const r=this.source;this.url=r.src;const n=()=>{this.destroyed||(r.onload=null,r.onerror=null,this.update(),this._load=null,this.createBitmap?e(this.process()):e(this))};r.complete&&r.src?n():(r.onload=n,r.onerror=a=>{s(a),this.onError.emit(a)})}),this._load)}process(){const t=this.source;if(this._process!==null)return this._process;if(this.bitmap!==null||!globalThis.createImageBitmap)return Promise.resolve(this);const e=globalThis.createImageBitmap,s=!t.crossOrigin||t.crossOrigin==="anonymous";return this._process=fetch(t.src,{mode:s?"cors":"no-cors"}).then(r=>r.blob()).then(r=>e(r,0,0,t.width,t.height,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===At.UNPACK?"premultiply":"none"})).then(r=>this.destroyed?Promise.reject():(this.bitmap=r,this.update(),this._process=null,Promise.resolve(this))),this._process}upload(t,e,s){if(typeof this.alphaMode=="number"&&(e.alphaMode=this.alphaMode),!this.createBitmap)return super.upload(t,e,s);if(!this.bitmap&&(this.process(),!this.bitmap))return!1;if(super.upload(t,e,s,this.bitmap),!this.preserveBitmap){let r=!0;const n=e._glTextures;for(const a in n){const o=n[a];if(o!==s&&o.dirtyId!==e.dirtyId){r=!1;break}}r&&(this.bitmap.close&&this.bitmap.close(),this.bitmap=null)}return!0}dispose(){this.source.onload=null,this.source.onerror=null,super.dispose(),this.bitmap&&(this.bitmap.close(),this.bitmap=null),this._process=null,this._load=null}static test(t){return typeof HTMLImageElement!="undefined"&&(typeof t=="string"||t instanceof HTMLImageElement)}}class cn{constructor(){this.x0=0,this.y0=0,this.x1=1,this.y1=0,this.x2=1,this.y2=1,this.x3=0,this.y3=1,this.uvsFloat32=new Float32Array(8)}set(t,e,s){const r=e.width,n=e.height;if(s){const a=t.width/2/r,o=t.height/2/n,h=t.x/r+a,l=t.y/n+o;s=at.add(s,at.NW),this.x0=h+a*at.uX(s),this.y0=l+o*at.uY(s),s=at.add(s,2),this.x1=h+a*at.uX(s),this.y1=l+o*at.uY(s),s=at.add(s,2),this.x2=h+a*at.uX(s),this.y2=l+o*at.uY(s),s=at.add(s,2),this.x3=h+a*at.uX(s),this.y3=l+o*at.uY(s)}else this.x0=t.x/r,this.y0=t.y/n,this.x1=(t.x+t.width)/r,this.y1=t.y/n,this.x2=(t.x+t.width)/r,this.y2=(t.y+t.height)/n,this.x3=t.x/r,this.y3=(t.y+t.height)/n;this.uvsFloat32[0]=this.x0,this.uvsFloat32[1]=this.y0,this.uvsFloat32[2]=this.x1,this.uvsFloat32[3]=this.y1,this.uvsFloat32[4]=this.x2,this.uvsFloat32[5]=this.y2,this.uvsFloat32[6]=this.x3,this.uvsFloat32[7]=this.y3}}const th=new cn;function Li(i){i.destroy=function(){},i.on=function(){},i.once=function(){},i.emit=function(){}}class L extends Ye{constructor(t,e,s,r,n,a,o){if(super(),this.noFrame=!1,e||(this.noFrame=!0,e=new z(0,0,1,1)),t instanceof L&&(t=t.baseTexture),this.baseTexture=t,this._frame=e,this.trim=r,this.valid=!1,this.destroyed=!1,this._uvs=th,this.uvMatrix=null,this.orig=s||e,this._rotate=Number(n||0),n===!0)this._rotate=2;else if(this._rotate%2!==0)throw new Error("attempt to use diamond-shaped UVs. If you are sure, set rotation manually");this.defaultAnchor=a?new K(a.x,a.y):new K(0,0),this.defaultBorders=o,this._updateID=0,this.textureCacheIds=[],t.valid?this.noFrame?t.valid&&this.onBaseTextureUpdated(t):this.frame=e:t.once("loaded",this.onBaseTextureUpdated,this),this.noFrame&&t.on("update",this.onBaseTextureUpdated,this)}update(){this.baseTexture.resource&&this.baseTexture.resource.update()}onBaseTextureUpdated(t){if(this.noFrame){if(!this.baseTexture.valid)return;this._frame.width=t.width,this._frame.height=t.height,this.valid=!0,this.updateUvs()}else this.frame=this._frame;this.emit("update",this)}destroy(t){if(this.baseTexture){if(t){const{resource:e}=this.baseTexture;e!=null&&e.url&&wt[e.url]&&L.removeFromCache(e.url),this.baseTexture.destroy()}this.baseTexture.off("loaded",this.onBaseTextureUpdated,this),this.baseTexture.off("update",this.onBaseTextureUpdated,this),this.baseTexture=null}this._frame=null,this._uvs=null,this.trim=null,this.orig=null,this.valid=!1,L.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0,this.emit("destroyed",this),this.removeAllListeners()}clone(){var t;const e=this._frame.clone(),s=this._frame===this.orig?e:this.orig.clone(),r=new L(this.baseTexture,!this.noFrame&&e,s,(t=this.trim)==null?void 0:t.clone(),this.rotate,this.defaultAnchor,this.defaultBorders);return this.noFrame&&(r._frame=e),r}updateUvs(){this._uvs===th&&(this._uvs=new cn),this._uvs.set(this._frame,this.baseTexture,this.rotate),this._updateID++}static from(t,e={},s=N.STRICT_TEXTURE_CACHE){const r=typeof t=="string";let n=null;if(r)n=t;else if(t instanceof X){if(!t.cacheId){const o=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t.cacheId=`${o}-${Te()}`,X.addToCache(t,t.cacheId)}n=t.cacheId}else{if(!t._pixiId){const o=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t._pixiId=`${o}_${Te()}`}n=t._pixiId}let a=wt[n];if(r&&s&&!a)throw new Error(`The cacheId "${n}" does not exist in TextureCache.`);return!a&&!(t instanceof X)?(e.resolution||(e.resolution=te(t)),a=new L(new X(t,e)),a.baseTexture.cacheId=n,X.addToCache(a.baseTexture,n),L.addToCache(a,n)):!a&&t instanceof X&&(a=new L(t),L.addToCache(a,n)),a}static fromURL(t,e){const s=Object.assign({autoLoad:!1},e==null?void 0:e.resourceOptions),r=L.from(t,Object.assign({resourceOptions:s},e),!1),n=r.baseTexture.resource;return r.baseTexture.valid?Promise.resolve(r):n.load().then(()=>Promise.resolve(r))}static fromBuffer(t,e,s,r){return new L(X.fromBuffer(t,e,s,r))}static fromLoader(t,e,s,r){const n=new X(t,Object.assign({scaleMode:X.defaultOptions.scaleMode,resolution:te(e)},r)),{resource:a}=n;a instanceof un&&(a.url=e);const o=new L(n);return s||(s=e),X.addToCache(o.baseTexture,s),L.addToCache(o,s),s!==e&&(X.addToCache(o.baseTexture,e),L.addToCache(o,e)),o.baseTexture.valid?Promise.resolve(o):new Promise(h=>{o.baseTexture.once("loaded",()=>h(o))})}static addToCache(t,e){e&&(t.textureCacheIds.includes(e)||t.textureCacheIds.push(e),wt[e]&&wt[e]!==t&&console.warn(`Texture added to the cache with an id [${e}] that already had an entry`),wt[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=wt[t];if(e){const s=e.textureCacheIds.indexOf(t);return s>-1&&e.textureCacheIds.splice(s,1),delete wt[t],e}}else if(t!=null&&t.textureCacheIds){for(let e=0;ethis.baseTexture.width,o=s+n>this.baseTexture.height;if(a||o){const h=a&&o?"and":"or",l=`X: ${e} + ${r} = ${e+r} > ${this.baseTexture.width}`,u=`Y: ${s} + ${n} = ${s+n} > ${this.baseTexture.height}`;throw new Error(`Texture Error: frame does not fit inside the base Texture dimensions: ${l} ${h} ${u}`)}this.valid=r&&n&&this.baseTexture.valid,!this.trim&&!this.rotate&&(this.orig=t),this.valid&&this.updateUvs()}get rotate(){return this._rotate}set rotate(t){this._rotate=t,this.valid&&this.updateUvs()}get width(){return this.orig.width}get height(){return this.orig.height}castToBaseTexture(){return this.baseTexture}static get EMPTY(){return L._EMPTY||(L._EMPTY=new L(new X),Li(L._EMPTY),Li(L._EMPTY.baseTexture)),L._EMPTY}static get WHITE(){if(!L._WHITE){const t=N.ADAPTER.createCanvas(16,16),e=t.getContext("2d");t.width=16,t.height=16,e.fillStyle="white",e.fillRect(0,0,16,16),L._WHITE=new L(X.from(t)),Li(L._WHITE),Li(L._WHITE.baseTexture)}return L._WHITE}}class Yt extends L{constructor(t,e){super(t,e),this.valid=!0,this.filterFrame=null,this.filterPoolKey=null,this.updateUvs()}get framebuffer(){return this.baseTexture.framebuffer}get multisample(){return this.framebuffer.multisample}set multisample(t){this.framebuffer.multisample=t}resize(t,e,s=!0){const r=this.baseTexture.resolution,n=Math.round(t*r)/r,a=Math.round(e*r)/r;this.valid=n>0&&a>0,this._frame.width=this.orig.width=n,this._frame.height=this.orig.height=a,s&&this.baseTexture.resize(n,a),this.updateUvs()}setResolution(t){const{baseTexture:e}=this;e.resolution!==t&&(e.setResolution(t),this.resize(e.width,e.height,!1))}static create(t){return new Yt(new Ni(t))}}class dn{constructor(t){this.texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this._pixelsWidth=0,this._pixelsHeight=0}createTexture(t,e,s=ft.NONE){const r=new Ni(Object.assign({width:t,height:e,resolution:1,multisample:s},this.textureOptions));return new Yt(r)}getOptimalTexture(t,e,s=1,r=ft.NONE){let n;t=Math.max(Math.ceil(t*s-1e-6),1),e=Math.max(Math.ceil(e*s-1e-6),1),!this.enableFullScreen||t!==this._pixelsWidth||e!==this._pixelsHeight?(t=vs(t),e=vs(e),n=((t&65535)<<16|e&65535)>>>0,r>1&&(n+=r*4294967296)):n=r>1?-r:-1,this.texturePool[n]||(this.texturePool[n]=[]);let a=this.texturePool[n].pop();return a||(a=this.createTexture(t,e,r)),a.filterPoolKey=n,a.setResolution(s),a}getFilterTexture(t,e,s){const r=this.getOptimalTexture(t.width,t.height,e||t.resolution,s||ft.NONE);return r.filterFrame=t.filterFrame,r}returnTexture(t){const e=t.filterPoolKey;t.filterFrame=null,this.texturePool[e].push(t)}returnFilterTexture(t){this.returnTexture(t)}clear(t){if(t=t!==!1,t)for(const e in this.texturePool){const s=this.texturePool[e];if(s)for(let r=0;r0&&t.height>0;for(const e in this.texturePool){if(!(Number(e)<0))continue;const s=this.texturePool[e];if(s)for(let r=0;r1&&(u=this.getOptimalFilterTexture(l.width,l.height,e.resolution),u.filterFrame=l.filterFrame),s[c].apply(this,l,u,Vt.CLEAR,e);const d=l;l=u,u=d}s[c].apply(this,l,h.renderTexture,Vt.BLEND,e),c>1&&e.multisample>1&&this.returnFilterTexture(e.renderTexture),this.returnFilterTexture(l),this.returnFilterTexture(u)}e.clear(),this.statePool.push(e)}bindAndClear(t,e=Vt.CLEAR){const{renderTexture:s,state:r}=this.renderer;if(t===this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?this.renderer.projection.transform=this.activeState.transform:this.renderer.projection.transform=null,t!=null&&t.filterFrame){const a=this.tempRect;a.x=0,a.y=0,a.width=t.filterFrame.width,a.height=t.filterFrame.height,s.bind(t,t.filterFrame,a)}else t!==this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?s.bind(t):this.renderer.renderTexture.bind(t,this.activeState.bindingSourceFrame,this.activeState.bindingDestinationFrame);const n=r.stateId&1||this.forceClear;(e===Vt.CLEAR||e===Vt.BLIT&&n)&&this.renderer.framebuffer.clear(0,0,0,0)}applyFilter(t,e,s,r){const n=this.renderer;n.state.set(t.state),this.bindAndClear(s,r),t.uniforms.uSampler=e,t.uniforms.filterGlobals=this.globalUniforms,n.shader.bind(t),t.legacy=!!t.program.attributeData.aTextureCoord,t.legacy?(this.quadUv.map(e._frame,e.filterFrame),n.geometry.bind(this.quadUv),n.geometry.draw(Ot.TRIANGLES)):(n.geometry.bind(this.quad),n.geometry.draw(Ot.TRIANGLE_STRIP))}calculateSpriteMatrix(t,e){const{sourceFrame:s,destinationFrame:r}=this.activeState,{orig:n}=e._texture,a=t.set(r.width,0,0,r.height,s.x,s.y),o=e.worldTransform.copyTo(tt.TEMP_MATRIX);return o.invert(),a.prepend(o),a.scale(1/n.width,1/n.height),a.translate(e.anchor.x,e.anchor.y),a}destroy(){this.renderer=null,this.texturePool.clear(!1)}getOptimalFilterTexture(t,e,s=1,r=ft.NONE){return this.texturePool.getOptimalTexture(t,e,s,r)}getFilterTexture(t,e,s){if(typeof t=="number"){const n=t;t=e,e=n}t=t||this.activeState.renderTexture;const r=this.texturePool.getOptimalTexture(t.width,t.height,e||t.resolution,s||ft.NONE);return r.filterFrame=t.filterFrame,r}returnFilterTexture(t){this.texturePool.returnTexture(t)}emptyPool(){this.texturePool.clear(!0)}resize(){this.texturePool.setScreenSize(this.renderer.view)}transformAABB(t,e){const s=Ui[0],r=Ui[1],n=Ui[2],a=Ui[3];s.set(e.left,e.top),r.set(e.left,e.bottom),n.set(e.right,e.top),a.set(e.right,e.bottom),t.apply(s,s),t.apply(r,r),t.apply(n,n),t.apply(a,a);const o=Math.min(s.x,r.x,n.x,a.x),h=Math.min(s.y,r.y,n.y,a.y),l=Math.max(s.x,r.x,n.x,a.x),u=Math.max(s.y,r.y,n.y,a.y);e.x=o,e.y=h,e.width=l-o,e.height=u-h}roundFrame(t,e,s,r,n){if(!(t.width<=0||t.height<=0||s.width<=0||s.height<=0)){if(n){const{a,b:o,c:h,d:l}=n;if((Math.abs(o)>1e-4||Math.abs(h)>1e-4)&&(Math.abs(a)>1e-4||Math.abs(l)>1e-4))return}n=n?pn.copyFrom(n):pn.identity(),n.translate(-s.x,-s.y).scale(r.width/s.width,r.height/s.height).translate(r.x,r.y),this.transformAABB(n,t),t.ceil(e),this.transformAABB(n.invert(),t)}}}mn.extension={type:D.RendererSystem,name:"filter"},U.add(mn);class ih{constructor(t){this.framebuffer=t,this.stencil=null,this.dirtyId=-1,this.dirtyFormat=-1,this.dirtySize=-1,this.multisample=ft.NONE,this.msaaBuffer=null,this.blitFramebuffer=null,this.mipLevel=0}}const Fd=new z;class gn{constructor(t){this.renderer=t,this.managedFramebuffers=[],this.unknownFramebuffer=new Fi(10,10),this.msaaSamples=null}contextChange(){this.disposeAll(!0);const t=this.gl=this.renderer.gl;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.current=this.unknownFramebuffer,this.viewport=new z,this.hasMRT=!0,this.writeDepthTexture=!0,this.renderer.context.webGLVersion===1){let e=this.renderer.context.extensions.drawBuffers,s=this.renderer.context.extensions.depthTexture;N.PREFER_ENV===be.WEBGL_LEGACY&&(e=null,s=null),e?t.drawBuffers=r=>e.drawBuffersWEBGL(r):(this.hasMRT=!1,t.drawBuffers=()=>{}),s||(this.writeDepthTexture=!1)}else this.msaaSamples=t.getInternalformatParameter(t.RENDERBUFFER,t.RGBA8,t.SAMPLES)}bind(t,e,s=0){const{gl:r}=this;if(t){const n=t.glFramebuffers[this.CONTEXT_UID]||this.initFramebuffer(t);this.current!==t&&(this.current=t,r.bindFramebuffer(r.FRAMEBUFFER,n.framebuffer)),n.mipLevel!==s&&(t.dirtyId++,t.dirtyFormat++,n.mipLevel=s),n.dirtyId!==t.dirtyId&&(n.dirtyId=t.dirtyId,n.dirtyFormat!==t.dirtyFormat?(n.dirtyFormat=t.dirtyFormat,n.dirtySize=t.dirtySize,this.updateFramebuffer(t,s)):n.dirtySize!==t.dirtySize&&(n.dirtySize=t.dirtySize,this.resizeFramebuffer(t)));for(let a=0;a>s,o=e.height>>s,h=a/e.width;this.setViewport(e.x*h,e.y*h,a,o)}else{const a=t.width>>s,o=t.height>>s;this.setViewport(0,0,a,o)}}else this.current&&(this.current=null,r.bindFramebuffer(r.FRAMEBUFFER,null)),e?this.setViewport(e.x,e.y,e.width,e.height):this.setViewport(0,0,this.renderer.width,this.renderer.height)}setViewport(t,e,s,r){const n=this.viewport;t=Math.round(t),e=Math.round(e),s=Math.round(s),r=Math.round(r),(n.width!==s||n.height!==r||n.x!==t||n.y!==e)&&(n.x=t,n.y=e,n.width=s,n.height=r,this.gl.viewport(t,e,s,r))}get size(){return this.current?{x:0,y:0,width:this.current.width,height:this.current.height}:{x:0,y:0,width:this.renderer.width,height:this.renderer.height}}clear(t,e,s,r,n=ui.COLOR|ui.DEPTH){const{gl:a}=this;a.clearColor(t,e,s,r),a.clear(n)}initFramebuffer(t){const{gl:e}=this,s=new ih(e.createFramebuffer());return s.multisample=this.detectSamples(t.multisample),t.glFramebuffers[this.CONTEXT_UID]=s,this.managedFramebuffers.push(t),t.disposeRunner.add(this),s}resizeFramebuffer(t){const{gl:e}=this,s=t.glFramebuffers[this.CONTEXT_UID];if(s.stencil){e.bindRenderbuffer(e.RENDERBUFFER,s.stencil);let a;this.renderer.context.webGLVersion===1?a=e.DEPTH_STENCIL:t.depth&&t.stencil?a=e.DEPTH24_STENCIL8:t.depth?a=e.DEPTH_COMPONENT24:a=e.STENCIL_INDEX8,s.msaaBuffer?e.renderbufferStorageMultisample(e.RENDERBUFFER,s.multisample,a,t.width,t.height):e.renderbufferStorage(e.RENDERBUFFER,a,t.width,t.height)}const r=t.colorTextures;let n=r.length;e.drawBuffers||(n=Math.min(n,1));for(let a=0;a1&&this.canMultisampleFramebuffer(t)?r.msaaBuffer=r.msaaBuffer||s.createRenderbuffer():r.msaaBuffer&&(s.deleteRenderbuffer(r.msaaBuffer),r.msaaBuffer=null,r.blitFramebuffer&&(r.blitFramebuffer.dispose(),r.blitFramebuffer=null));const o=[];for(let h=0;h1&&s.drawBuffers(o),t.depthTexture&&this.writeDepthTexture){const h=t.depthTexture;this.renderer.texture.bind(h,0),s.framebufferTexture2D(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.TEXTURE_2D,h._glTextures[this.CONTEXT_UID].texture,e)}if((t.stencil||t.depth)&&!(t.depthTexture&&this.writeDepthTexture)){r.stencil=r.stencil||s.createRenderbuffer();let h,l;this.renderer.context.webGLVersion===1?(h=s.DEPTH_STENCIL_ATTACHMENT,l=s.DEPTH_STENCIL):t.depth&&t.stencil?(h=s.DEPTH_STENCIL_ATTACHMENT,l=s.DEPTH24_STENCIL8):t.depth?(h=s.DEPTH_ATTACHMENT,l=s.DEPTH_COMPONENT24):(h=s.STENCIL_ATTACHMENT,l=s.STENCIL_INDEX8),s.bindRenderbuffer(s.RENDERBUFFER,r.stencil),r.msaaBuffer?s.renderbufferStorageMultisample(s.RENDERBUFFER,r.multisample,l,t.width,t.height):s.renderbufferStorage(s.RENDERBUFFER,l,t.width,t.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,h,s.RENDERBUFFER,r.stencil)}else r.stencil&&(s.deleteRenderbuffer(r.stencil),r.stencil=null)}canMultisampleFramebuffer(t){return this.renderer.context.webGLVersion!==1&&t.colorTextures.length<=1&&!t.depthTexture}detectSamples(t){const{msaaSamples:e}=this;let s=ft.NONE;if(t<=1||e===null)return s;for(let r=0;r=0&&this.managedFramebuffers.splice(n,1),t.disposeRunner.remove(this),e||(r.deleteFramebuffer(s.framebuffer),s.msaaBuffer&&r.deleteRenderbuffer(s.msaaBuffer),s.stencil&&r.deleteRenderbuffer(s.stencil)),s.blitFramebuffer&&this.disposeFramebuffer(s.blitFramebuffer,e)}disposeAll(t){const e=this.managedFramebuffers;this.managedFramebuffers=[];for(let s=0;ss.createVertexArrayOES(),t.bindVertexArray=r=>s.bindVertexArrayOES(r),t.deleteVertexArray=r=>s.deleteVertexArrayOES(r)):(this.hasVao=!1,t.createVertexArray=()=>null,t.bindVertexArray=()=>null,t.deleteVertexArray=()=>null)}if(e.webGLVersion!==2){const s=t.getExtension("ANGLE_instanced_arrays");s?(t.vertexAttribDivisor=(r,n)=>s.vertexAttribDivisorANGLE(r,n),t.drawElementsInstanced=(r,n,a,o,h)=>s.drawElementsInstancedANGLE(r,n,a,o,h),t.drawArraysInstanced=(r,n,a,o)=>s.drawArraysInstancedANGLE(r,n,a,o)):this.hasInstance=!1}this.canUseUInt32ElementIndex=e.webGLVersion===2||!!e.extensions.uint32ElementIndex}bind(t,e){e=e||this.renderer.shader.shader;const{gl:s}=this;let r=t.glVertexArrayObjects[this.CONTEXT_UID],n=!1;r||(this.managedGeometries[t.id]=t,t.disposeRunner.add(this),t.glVertexArrayObjects[this.CONTEXT_UID]=r={},n=!0);const a=r[e.program.id]||this.initGeometryVao(t,e,n);this._activeGeometry=t,this._activeVao!==a&&(this._activeVao=a,this.hasVao?s.bindVertexArray(a):this.activateVao(t,e.program)),this.updateBuffers()}reset(){this.unbind()}updateBuffers(){const t=this._activeGeometry,e=this.renderer.buffer;for(let s=0;s0?this.maskStack[this.maskStack.length-1]._colorMask:15;s!==e&&this.renderer.gl.colorMask((s&1)!==0,(s&2)!==0,(s&4)!==0,(s&8)!==0)}destroy(){this.renderer=null}}yn.extension={type:D.RendererSystem,name:"mask"},U.add(yn);class oh{constructor(t){this.renderer=t,this.maskStack=[],this.glConst=0}getStackLength(){return this.maskStack.length}setMaskStack(t){const{gl:e}=this.renderer,s=this.getStackLength();this.maskStack=t;const r=this.getStackLength();r!==s&&(r===0?e.disable(this.glConst):(e.enable(this.glConst),this._useCurrent()))}_useCurrent(){}destroy(){this.renderer=null,this.maskStack=null}}const hh=new tt,lh=[],uh=class xr extends oh{constructor(t){super(t),this.glConst=N.ADAPTER.getWebGLRenderingContext().SCISSOR_TEST}getStackLength(){const t=this.maskStack[this.maskStack.length-1];return t?t._scissorCounter:0}calcScissorRect(t){var e;if(t._scissorRectLocal)return;const s=t._scissorRect,{maskObject:r}=t,{renderer:n}=this,a=n.renderTexture,o=r.getBounds(!0,(e=lh.pop())!=null?e:new z);this.roundFrameToPixels(o,a.current?a.current.resolution:n.resolution,a.sourceFrame,a.destinationFrame,n.projection.transform),s&&o.fit(s),t._scissorRectLocal=o}static isMatrixRotated(t){if(!t)return!1;const{a:e,b:s,c:r,d:n}=t;return(Math.abs(s)>1e-4||Math.abs(r)>1e-4)&&(Math.abs(e)>1e-4||Math.abs(n)>1e-4)}testScissor(t){const{maskObject:e}=t;if(!e.isFastRect||!e.isFastRect()||xr.isMatrixRotated(e.worldTransform)||xr.isMatrixRotated(this.renderer.projection.transform))return!1;this.calcScissorRect(t);const s=t._scissorRectLocal;return s.width>0&&s.height>0}roundFrameToPixels(t,e,s,r,n){xr.isMatrixRotated(n)||(n=n?hh.copyFrom(n):hh.identity(),n.translate(-s.x,-s.y).scale(r.width/s.width,r.height/s.height).translate(r.x,r.y),this.renderer.filter.transformAABB(n,t),t.fit(r),t.x=Math.round(t.x*e),t.y=Math.round(t.y*e),t.width=Math.round(t.width*e),t.height=Math.round(t.height*e))}push(t){t._scissorRectLocal||this.calcScissorRect(t);const{gl:e}=this.renderer;t._scissorRect||e.enable(e.SCISSOR_TEST),t._scissorCounter++,t._scissorRect=t._scissorRectLocal,this._useCurrent()}pop(t){const{gl:e}=this.renderer;t&&lh.push(t._scissorRectLocal),this.getStackLength()>0?this._useCurrent():e.disable(e.SCISSOR_TEST)}_useCurrent(){const t=this.maskStack[this.maskStack.length-1]._scissorRect;let e;this.renderer.renderTexture.current?e=t.y:e=this.renderer.height-t.height-t.y,this.renderer.gl.scissor(t.x,e,t.width,t.height)}};uh.extension={type:D.RendererSystem,name:"scissor"};let ch=uh;U.add(ch);class xn extends oh{constructor(t){super(t),this.glConst=N.ADAPTER.getWebGLRenderingContext().STENCIL_TEST}getStackLength(){const t=this.maskStack[this.maskStack.length-1];return t?t._stencilCounter:0}push(t){const e=t.maskObject,{gl:s}=this.renderer,r=t._stencilCounter;r===0&&(this.renderer.framebuffer.forceStencil(),s.clearStencil(0),s.clear(s.STENCIL_BUFFER_BIT),s.enable(s.STENCIL_TEST)),t._stencilCounter++;const n=t._colorMask;n!==0&&(t._colorMask=0,s.colorMask(!1,!1,!1,!1)),s.stencilFunc(s.EQUAL,r,4294967295),s.stencilOp(s.KEEP,s.KEEP,s.INCR),e.renderable=!0,e.render(this.renderer),this.renderer.batch.flush(),e.renderable=!1,n!==0&&(t._colorMask=n,s.colorMask((n&1)!==0,(n&2)!==0,(n&4)!==0,(n&8)!==0)),this._useCurrent()}pop(t){const e=this.renderer.gl;if(this.getStackLength()===0)e.disable(e.STENCIL_TEST);else{const s=this.maskStack.length!==0?this.maskStack[this.maskStack.length-1]:null,r=s?s._colorMask:15;r!==0&&(s._colorMask=0,e.colorMask(!1,!1,!1,!1)),e.stencilOp(e.KEEP,e.KEEP,e.DECR),t.renderable=!0,t.render(this.renderer),this.renderer.batch.flush(),t.renderable=!1,r!==0&&(s._colorMask=r,e.colorMask((r&1)!==0,(r&2)!==0,(r&4)!==0,(r&8)!==0)),this._useCurrent()}}_useCurrent(){const t=this.renderer.gl;t.stencilFunc(t.EQUAL,this.getStackLength(),4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP)}}xn.extension={type:D.RendererSystem,name:"stencil"},U.add(xn);class bn{constructor(t){this.renderer=t,this.plugins={}}init(){const t=this.rendererPlugins;for(const e in t)this.plugins[e]=new t[e](this.renderer)}destroy(){for(const t in this.plugins)this.plugins[t].destroy(),this.plugins[t]=null}}bn.extension={type:[D.RendererSystem,D.CanvasRendererSystem],name:"_plugin"},U.add(bn);class Tn{constructor(t){this.renderer=t,this.destinationFrame=null,this.sourceFrame=null,this.defaultFrame=null,this.projectionMatrix=new tt,this.transform=null}update(t,e,s,r){this.destinationFrame=t||this.destinationFrame||this.defaultFrame,this.sourceFrame=e||this.sourceFrame||t,this.calculateProjection(this.destinationFrame,this.sourceFrame,s,r),this.transform&&this.projectionMatrix.append(this.transform);const n=this.renderer;n.globalUniforms.uniforms.projectionMatrix=this.projectionMatrix,n.globalUniforms.update(),n.shader.shader&&n.shader.syncUniformGroup(n.shader.shader.uniforms.globals)}calculateProjection(t,e,s,r){const n=this.projectionMatrix,a=r?-1:1;n.identity(),n.a=1/e.width*2,n.d=a*(1/e.height*2),n.tx=-1-e.x*n.a,n.ty=-a-e.y*n.d}setTransform(t){}destroy(){this.renderer=null}}Tn.extension={type:D.RendererSystem,name:"projection"},U.add(Tn);var dh=Object.getOwnPropertySymbols,Ud=Object.prototype.hasOwnProperty,kd=Object.prototype.propertyIsEnumerable,Gd=(i,t)=>{var e={};for(var s in i)Ud.call(i,s)&&t.indexOf(s)<0&&(e[s]=i[s]);if(i!=null&&dh)for(var s of dh(i))t.indexOf(s)<0&&kd.call(i,s)&&(e[s]=i[s]);return e};const $d=new Pi,fh=new z;class En{constructor(t){this.renderer=t,this._tempMatrix=new tt}generateTexture(t,e){var s;const r=e||{},{region:n}=r,a=Gd(r,["region"]),o=(n==null?void 0:n.copyTo(fh))||t.getLocalBounds(fh,!0),h=a.resolution||this.renderer.resolution;o.width=Math.max(o.width,1/h),o.height=Math.max(o.height,1/h),a.width=o.width,a.height=o.height,a.resolution=h,(s=a.multisample)!=null||(a.multisample=this.renderer.multisample);const l=Yt.create(a);this._tempMatrix.tx=-o.x,this._tempMatrix.ty=-o.y;const u=t.transform;return t.transform=$d,this.renderer.render(t,{renderTexture:l,transform:this._tempMatrix,skipUpdateTransform:!!t.parent,blit:!0}),t.transform=u,l}destroy(){}}En.extension={type:[D.RendererSystem,D.CanvasRendererSystem],name:"textureGenerator"},U.add(En);const Ge=new z,Is=new z;class An{constructor(t){this.renderer=t,this.defaultMaskStack=[],this.current=null,this.sourceFrame=new z,this.destinationFrame=new z,this.viewportFrame=new z}contextChange(){var t;const e=(t=this.renderer)==null?void 0:t.gl.getContextAttributes();this._rendererPremultipliedAlpha=!!(e&&e.alpha&&e.premultipliedAlpha)}bind(t=null,e,s){const r=this.renderer;this.current=t;let n,a,o;t?(n=t.baseTexture,o=n.resolution,e||(Ge.width=t.frame.width,Ge.height=t.frame.height,e=Ge),s||(Is.x=t.frame.x,Is.y=t.frame.y,Is.width=e.width,Is.height=e.height,s=Is),a=n.framebuffer):(o=r.resolution,e||(Ge.width=r._view.screen.width,Ge.height=r._view.screen.height,e=Ge),s||(s=Ge,s.width=e.width,s.height=e.height));const h=this.viewportFrame;h.x=s.x*o,h.y=s.y*o,h.width=s.width*o,h.height=s.height*o,t||(h.y=r.view.height-(h.y+h.height)),h.ceil(),this.renderer.framebuffer.bind(a,h),this.renderer.projection.update(s,e,o,!a),t?this.renderer.mask.setMaskStack(n.maskStack):this.renderer.mask.setMaskStack(this.defaultMaskStack),this.sourceFrame.copyFrom(e),this.destinationFrame.copyFrom(s)}clear(t,e){const s=this.current?this.current.baseTexture.clear:this.renderer.background.backgroundColor,r=Y.shared.setValue(t||s);(this.current&&this.current.baseTexture.alphaMode>0||!this.current&&this._rendererPremultipliedAlpha)&&r.premultiply(r.alpha);const n=this.destinationFrame,a=this.current?this.current.baseTexture:this.renderer._view.screen,o=n.width!==a.width||n.height!==a.height;if(o){let{x:h,y:l,width:u,height:c}=this.viewportFrame;h=Math.round(h),l=Math.round(l),u=Math.round(u),c=Math.round(c),this.renderer.gl.enable(this.renderer.gl.SCISSOR_TEST),this.renderer.gl.scissor(h,l,u,c)}this.renderer.framebuffer.clear(r.red,r.green,r.blue,r.alpha,e),o&&this.renderer.scissor.pop()}resize(){this.bind(null)}reset(){this.bind(null)}destroy(){this.renderer=null}}An.extension={type:D.RendererSystem,name:"renderTexture"},U.add(An);class Hd{}class ph{constructor(t,e){this.program=t,this.uniformData=e,this.uniformGroups={},this.uniformDirtyGroups={},this.uniformBufferBindings={}}destroy(){this.uniformData=null,this.uniformGroups=null,this.uniformDirtyGroups=null,this.uniformBufferBindings=null,this.program=null}}function Vd(i,t){const e={},s=t.getProgramParameter(i,t.ACTIVE_ATTRIBUTES);for(let r=0;rl>u?1:-1);for(let l=0;l({data:n,offset:0,dataLen:0,dirty:0}));let e=0,s=0,r=0;for(let n=0;n1&&(e=Math.max(e,16)*a.data.size),a.dataLen=e,s%e!==0&&s<16){const o=s%e%16;s+=o,r+=o}s+e>16?(r=Math.ceil(r/16)*16,a.offset=r,r+=e,s=e):(a.offset=r,s+=e,r+=e)}return r=Math.ceil(r/16)*16,{uboElements:t,size:r}}function vh(i,t){const e=[];for(const s in i)t[s]&&e.push(t[s]);return e.sort((s,r)=>s.index-r.index),e}function yh(i,t){if(!i.autoManage)return{size:0,syncFunc:Xd};const e=vh(i.uniforms,t),{uboElements:s,size:r}=_h(e),n=[` + var v = null; + var v2 = null; + var cv = null; + var t = 0; + var gl = renderer.gl + var index = 0; + var data = buffer.data; + `];for(let a=0;a1){const c=Wo(o.data.type),d=Math.max(gh[o.data.type]/16,1),f=c/d,p=(4-f%4)%4;n.push(` + cv = ud.${l}.value; + v = uv.${l}; + offset = ${o.offset/4}; + + t = 0; + + for(var i=0; i < ${o.data.size*d}; i++) + { + for(var j = 0; j < ${f}; j++) + { + data[offset++] = v[t++]; + } + offset += ${p}; + } + + `)}else{const c=zd[o.data.type];n.push(` + cv = ud.${l}.value; + v = uv.${l}; + offset = ${o.offset/4}; + ${c}; + `)}}return n.push(` + renderer.buffer.update(buffer); + `),{size:r,syncFunc:new Function("ud","uv","renderer","syncData","buffer",n.join(` +`))}}let Wd=0;const Gi={textureCount:0,uboCount:0};class wn{constructor(t){this.destroyed=!1,this.renderer=t,this.systemCheck(),this.gl=null,this.shader=null,this.program=null,this.cache={},this._uboCache={},this.id=Wd++}systemCheck(){if(!Zo())throw new Error("Current environment does not allow unsafe-eval, please use @pixi/unsafe-eval module to enable support.")}contextChange(t){this.gl=t,this.reset()}bind(t,e){t.disposeRunner.add(this),t.uniforms.globals=this.renderer.globalUniforms;const s=t.program,r=s.glPrograms[this.renderer.CONTEXT_UID]||this.generateProgram(t);return this.shader=t,this.program!==s&&(this.program=s,this.gl.useProgram(r.program)),e||(Gi.textureCount=0,Gi.uboCount=0,this.syncUniformGroup(t.uniformGroup,Gi)),r}setUniforms(t){const e=this.shader.program,s=e.glPrograms[this.renderer.CONTEXT_UID];e.syncUniforms(s.uniformData,t,this.renderer)}syncUniformGroup(t,e){const s=this.getGlProgram();(!t.static||t.dirtyId!==s.uniformDirtyGroups[t.id])&&(s.uniformDirtyGroups[t.id]=t.dirtyId,this.syncUniforms(t,s,e))}syncUniforms(t,e,s){(t.syncUniforms[this.shader.program.id]||this.createSyncGroups(t))(e.uniformData,t.uniforms,this.renderer,s)}createSyncGroups(t){const e=this.getSignature(t,this.shader.program.uniformData,"u");return this.cache[e]||(this.cache[e]=Ed(t,this.shader.program.uniformData)),t.syncUniforms[this.shader.program.id]=this.cache[e],t.syncUniforms[this.shader.program.id]}syncUniformBufferGroup(t,e){const s=this.getGlProgram();if(!t.static||t.dirtyId!==0||!s.uniformGroups[t.id]){t.dirtyId=0;const r=s.uniformGroups[t.id]||this.createSyncBufferGroup(t,s,e);t.buffer.update(),r(s.uniformData,t.uniforms,this.renderer,Gi,t.buffer)}this.renderer.buffer.bindBufferBase(t.buffer,s.uniformBufferBindings[e])}createSyncBufferGroup(t,e,s){const{gl:r}=this.renderer;this.renderer.buffer.bind(t.buffer);const n=this.gl.getUniformBlockIndex(e.program,s);e.uniformBufferBindings[s]=this.shader.uniformBindCount,r.uniformBlockBinding(e.program,n,this.shader.uniformBindCount),this.shader.uniformBindCount++;const a=this.getSignature(t,this.shader.program.uniformData,"ubo");let o=this._uboCache[a];if(o||(o=this._uboCache[a]=yh(t,this.shader.program.uniformData)),t.autoManage){const h=new Float32Array(o.size/4);t.buffer.update(h)}return e.uniformGroups[t.id]=o.syncFunc,e.uniformGroups[t.id]}getSignature(t,e,s){const r=t.uniforms,n=[`${s}-`];for(const a in r)n.push(a),e[a]&&n.push(e[a].type);return n.join("-")}getGlProgram(){return this.shader?this.shader.program.glPrograms[this.renderer.CONTEXT_UID]:null}generateProgram(t){const e=this.gl,s=t.program,r=mh(e,s);return s.glPrograms[this.renderer.CONTEXT_UID]=r,r}reset(){this.program=null,this.shader=null}disposeShader(t){this.shader===t&&(this.shader=null)}destroy(){this.renderer=null,this.destroyed=!0}}wn.extension={type:D.RendererSystem,name:"shader"},U.add(wn);class Ps{constructor(t){this.renderer=t}run(t){const{renderer:e}=this;e.runners.init.emit(e.options),t.hello&&console.log(`PixiJS 7.3.0 - ${e.rendererLogId} - https://pixijs.com`),e.resize(e.screen.width,e.screen.height)}destroy(){}}Ps.defaultOptions={hello:!1},Ps.extension={type:[D.RendererSystem,D.CanvasRendererSystem],name:"startup"},U.add(Ps);function Yd(i,t=[]){return t[C.NORMAL]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[C.ADD]=[i.ONE,i.ONE],t[C.MULTIPLY]=[i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA],t[C.SCREEN]=[i.ONE,i.ONE_MINUS_SRC_COLOR,i.ONE,i.ONE_MINUS_SRC_ALPHA],t[C.OVERLAY]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[C.DARKEN]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[C.LIGHTEN]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[C.COLOR_DODGE]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[C.COLOR_BURN]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[C.HARD_LIGHT]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[C.SOFT_LIGHT]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[C.DIFFERENCE]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[C.EXCLUSION]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[C.HUE]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[C.SATURATION]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[C.COLOR]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[C.LUMINOSITY]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[C.NONE]=[0,0],t[C.NORMAL_NPM]=[i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA],t[C.ADD_NPM]=[i.SRC_ALPHA,i.ONE,i.ONE,i.ONE],t[C.SCREEN_NPM]=[i.SRC_ALPHA,i.ONE_MINUS_SRC_COLOR,i.ONE,i.ONE_MINUS_SRC_ALPHA],t[C.SRC_IN]=[i.DST_ALPHA,i.ZERO],t[C.SRC_OUT]=[i.ONE_MINUS_DST_ALPHA,i.ZERO],t[C.SRC_ATOP]=[i.DST_ALPHA,i.ONE_MINUS_SRC_ALPHA],t[C.DST_OVER]=[i.ONE_MINUS_DST_ALPHA,i.ONE],t[C.DST_IN]=[i.ZERO,i.SRC_ALPHA],t[C.DST_OUT]=[i.ZERO,i.ONE_MINUS_SRC_ALPHA],t[C.DST_ATOP]=[i.ONE_MINUS_DST_ALPHA,i.SRC_ALPHA],t[C.XOR]=[i.ONE_MINUS_DST_ALPHA,i.ONE_MINUS_SRC_ALPHA],t[C.SUBTRACT]=[i.ONE,i.ONE,i.ONE,i.ONE,i.FUNC_REVERSE_SUBTRACT,i.FUNC_ADD],t}const qd=0,Kd=1,Zd=2,Qd=3,Jd=4,tf=5,xh=class Ta{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=C.NONE,this._blendEq=!1,this.map=[],this.map[qd]=this.setBlend,this.map[Kd]=this.setOffset,this.map[Zd]=this.setCullFace,this.map[Qd]=this.setDepthTest,this.map[Jd]=this.setFrontFace,this.map[tf]=this.setDepthMask,this.checks=[],this.defaultState=new ee,this.defaultState.blend=!0}contextChange(t){this.gl=t,this.blendModes=Yd(t),this.set(this.defaultState),this.reset()}set(t){if(t=t||this.defaultState,this.stateId!==t.data){let e=this.stateId^t.data,s=0;for(;e;)e&1&&this.map[s].call(this,!!(t.data&1<>1,s++;this.stateId=t.data}for(let e=0;et.systems[n]),r=[...s,...Object.keys(t.systems).filter(n=>!s.includes(n))];for(const n of r)this.addSystem(t.systems[n],n)}addRunners(...t){t.forEach(e=>{this.runners[e]=new Pt(e)})}addSystem(t,e){const s=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=s,this._systemsHash[e]=s;for(const r in this.runners)this.runners[r].add(s);return this}emitWithCustomOptions(t,e){const s=Object.keys(this._systemsHash);t.items.forEach(r=>{const n=s.find(a=>this._systemsHash[a]===r);r[t.name](e[n])})}destroy(){Object.values(this.runners).forEach(t=>{t.destroy()}),this._systemsHash={}}}const Ms=class br{constructor(t){this.renderer=t,this.count=0,this.checkCount=0,this.maxIdle=br.defaultMaxIdle,this.checkCountMax=br.defaultCheckCountMax,this.mode=br.defaultMode}postrender(){this.renderer.objectRenderer.renderingToScreen&&(this.count++,this.mode!==ci.MANUAL&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run())))}run(){const t=this.renderer.texture,e=t.managedTextures;let s=!1;for(let r=0;rthis.maxIdle&&(t.destroyTexture(n,!0),e[r]=null,s=!0)}if(s){let r=0;for(let n=0;n=0;r--)this.unload(t.children[r])}destroy(){this.renderer=null}};Ms.defaultMode=ci.AUTO,Ms.defaultMaxIdle=3600,Ms.defaultCheckCountMax=600,Ms.extension={type:D.RendererSystem,name:"textureGC"};let Ae=Ms;U.add(Ae);class $i{constructor(t){this.texture=t,this.width=-1,this.height=-1,this.dirtyId=-1,this.dirtyStyleId=-1,this.mipmap=!1,this.wrapMode=33071,this.type=$.UNSIGNED_BYTE,this.internalFormat=M.RGBA,this.samplerType=0}}function ef(i){let t;return"WebGL2RenderingContext"in globalThis&&i instanceof globalThis.WebGL2RenderingContext?t={[i.RGB]:k.FLOAT,[i.RGBA]:k.FLOAT,[i.ALPHA]:k.FLOAT,[i.LUMINANCE]:k.FLOAT,[i.LUMINANCE_ALPHA]:k.FLOAT,[i.R8]:k.FLOAT,[i.R8_SNORM]:k.FLOAT,[i.RG8]:k.FLOAT,[i.RG8_SNORM]:k.FLOAT,[i.RGB8]:k.FLOAT,[i.RGB8_SNORM]:k.FLOAT,[i.RGB565]:k.FLOAT,[i.RGBA4]:k.FLOAT,[i.RGB5_A1]:k.FLOAT,[i.RGBA8]:k.FLOAT,[i.RGBA8_SNORM]:k.FLOAT,[i.RGB10_A2]:k.FLOAT,[i.RGB10_A2UI]:k.FLOAT,[i.SRGB8]:k.FLOAT,[i.SRGB8_ALPHA8]:k.FLOAT,[i.R16F]:k.FLOAT,[i.RG16F]:k.FLOAT,[i.RGB16F]:k.FLOAT,[i.RGBA16F]:k.FLOAT,[i.R32F]:k.FLOAT,[i.RG32F]:k.FLOAT,[i.RGB32F]:k.FLOAT,[i.RGBA32F]:k.FLOAT,[i.R11F_G11F_B10F]:k.FLOAT,[i.RGB9_E5]:k.FLOAT,[i.R8I]:k.INT,[i.R8UI]:k.UINT,[i.R16I]:k.INT,[i.R16UI]:k.UINT,[i.R32I]:k.INT,[i.R32UI]:k.UINT,[i.RG8I]:k.INT,[i.RG8UI]:k.UINT,[i.RG16I]:k.INT,[i.RG16UI]:k.UINT,[i.RG32I]:k.INT,[i.RG32UI]:k.UINT,[i.RGB8I]:k.INT,[i.RGB8UI]:k.UINT,[i.RGB16I]:k.INT,[i.RGB16UI]:k.UINT,[i.RGB32I]:k.INT,[i.RGB32UI]:k.UINT,[i.RGBA8I]:k.INT,[i.RGBA8UI]:k.UINT,[i.RGBA16I]:k.INT,[i.RGBA16UI]:k.UINT,[i.RGBA32I]:k.INT,[i.RGBA32UI]:k.UINT,[i.DEPTH_COMPONENT16]:k.FLOAT,[i.DEPTH_COMPONENT24]:k.FLOAT,[i.DEPTH_COMPONENT32F]:k.FLOAT,[i.DEPTH_STENCIL]:k.FLOAT,[i.DEPTH24_STENCIL8]:k.FLOAT,[i.DEPTH32F_STENCIL8]:k.FLOAT}:t={[i.RGB]:k.FLOAT,[i.RGBA]:k.FLOAT,[i.ALPHA]:k.FLOAT,[i.LUMINANCE]:k.FLOAT,[i.LUMINANCE_ALPHA]:k.FLOAT,[i.DEPTH_STENCIL]:k.FLOAT},t}function sf(i){let t;return"WebGL2RenderingContext"in globalThis&&i instanceof globalThis.WebGL2RenderingContext?t={[$.UNSIGNED_BYTE]:{[M.RGBA]:i.RGBA8,[M.RGB]:i.RGB8,[M.RG]:i.RG8,[M.RED]:i.R8,[M.RGBA_INTEGER]:i.RGBA8UI,[M.RGB_INTEGER]:i.RGB8UI,[M.RG_INTEGER]:i.RG8UI,[M.RED_INTEGER]:i.R8UI,[M.ALPHA]:i.ALPHA,[M.LUMINANCE]:i.LUMINANCE,[M.LUMINANCE_ALPHA]:i.LUMINANCE_ALPHA},[$.BYTE]:{[M.RGBA]:i.RGBA8_SNORM,[M.RGB]:i.RGB8_SNORM,[M.RG]:i.RG8_SNORM,[M.RED]:i.R8_SNORM,[M.RGBA_INTEGER]:i.RGBA8I,[M.RGB_INTEGER]:i.RGB8I,[M.RG_INTEGER]:i.RG8I,[M.RED_INTEGER]:i.R8I},[$.UNSIGNED_SHORT]:{[M.RGBA_INTEGER]:i.RGBA16UI,[M.RGB_INTEGER]:i.RGB16UI,[M.RG_INTEGER]:i.RG16UI,[M.RED_INTEGER]:i.R16UI,[M.DEPTH_COMPONENT]:i.DEPTH_COMPONENT16},[$.SHORT]:{[M.RGBA_INTEGER]:i.RGBA16I,[M.RGB_INTEGER]:i.RGB16I,[M.RG_INTEGER]:i.RG16I,[M.RED_INTEGER]:i.R16I},[$.UNSIGNED_INT]:{[M.RGBA_INTEGER]:i.RGBA32UI,[M.RGB_INTEGER]:i.RGB32UI,[M.RG_INTEGER]:i.RG32UI,[M.RED_INTEGER]:i.R32UI,[M.DEPTH_COMPONENT]:i.DEPTH_COMPONENT24},[$.INT]:{[M.RGBA_INTEGER]:i.RGBA32I,[M.RGB_INTEGER]:i.RGB32I,[M.RG_INTEGER]:i.RG32I,[M.RED_INTEGER]:i.R32I},[$.FLOAT]:{[M.RGBA]:i.RGBA32F,[M.RGB]:i.RGB32F,[M.RG]:i.RG32F,[M.RED]:i.R32F,[M.DEPTH_COMPONENT]:i.DEPTH_COMPONENT32F},[$.HALF_FLOAT]:{[M.RGBA]:i.RGBA16F,[M.RGB]:i.RGB16F,[M.RG]:i.RG16F,[M.RED]:i.R16F},[$.UNSIGNED_SHORT_5_6_5]:{[M.RGB]:i.RGB565},[$.UNSIGNED_SHORT_4_4_4_4]:{[M.RGBA]:i.RGBA4},[$.UNSIGNED_SHORT_5_5_5_1]:{[M.RGBA]:i.RGB5_A1},[$.UNSIGNED_INT_2_10_10_10_REV]:{[M.RGBA]:i.RGB10_A2,[M.RGBA_INTEGER]:i.RGB10_A2UI},[$.UNSIGNED_INT_10F_11F_11F_REV]:{[M.RGB]:i.R11F_G11F_B10F},[$.UNSIGNED_INT_5_9_9_9_REV]:{[M.RGB]:i.RGB9_E5},[$.UNSIGNED_INT_24_8]:{[M.DEPTH_STENCIL]:i.DEPTH24_STENCIL8},[$.FLOAT_32_UNSIGNED_INT_24_8_REV]:{[M.DEPTH_STENCIL]:i.DEPTH32F_STENCIL8}}:t={[$.UNSIGNED_BYTE]:{[M.RGBA]:i.RGBA,[M.RGB]:i.RGB,[M.ALPHA]:i.ALPHA,[M.LUMINANCE]:i.LUMINANCE,[M.LUMINANCE_ALPHA]:i.LUMINANCE_ALPHA},[$.UNSIGNED_SHORT_5_6_5]:{[M.RGB]:i.RGB},[$.UNSIGNED_SHORT_4_4_4_4]:{[M.RGBA]:i.RGBA},[$.UNSIGNED_SHORT_5_5_5_1]:{[M.RGBA]:i.RGBA}},t}class Cn{constructor(t){this.renderer=t,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new X,this.hasIntegerTextures=!1}contextChange(){const t=this.gl=this.renderer.gl;this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.webGLVersion=this.renderer.context.webGLVersion,this.internalFormats=sf(t),this.samplerTypes=ef(t);const e=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);this.boundTextures.length=e;for(let r=0;r=0;--n){const a=e[n];a&&a._glTextures[r].samplerType!==k.FLOAT&&this.renderer.texture.unbind(a)}}initTexture(t){const e=new $i(this.gl.createTexture());return e.dirtyId=-1,t._glTextures[this.CONTEXT_UID]=e,this.managedTextures.push(t),t.on("dispose",this.destroyTexture,this),e}initTextureType(t,e){var s,r,n;e.internalFormat=(r=(s=this.internalFormats[t.type])==null?void 0:s[t.format])!=null?r:t.format,e.samplerType=(n=this.samplerTypes[e.internalFormat])!=null?n:k.FLOAT,this.webGLVersion===2&&t.type===$.HALF_FLOAT?e.type=this.gl.HALF_FLOAT:e.type=t.type}updateTexture(t){var e;const s=t._glTextures[this.CONTEXT_UID];if(!s)return;const r=this.renderer;if(this.initTextureType(t,s),(e=t.resource)!=null&&e.upload(r,t,s))s.samplerType!==k.FLOAT&&(this.hasIntegerTextures=!0);else{const n=t.realWidth,a=t.realHeight,o=r.gl;(s.width!==n||s.height!==a||s.dirtyId<0)&&(s.width=n,s.height=a,o.texImage2D(t.target,0,s.internalFormat,n,a,0,t.format,s.type,null))}t.dirtyStyleId!==s.dirtyStyleId&&this.updateTextureStyle(t),s.dirtyId=t.dirtyId}destroyTexture(t,e){const{gl:s}=this;if(t=t.castToBaseTexture(),t._glTextures[this.CONTEXT_UID]&&(this.unbind(t),s.deleteTexture(t._glTextures[this.CONTEXT_UID].texture),t.off("dispose",this.destroyTexture,this),delete t._glTextures[this.CONTEXT_UID],!e)){const r=this.managedTextures.indexOf(t);r!==-1&&Oe(this.managedTextures,r,1)}}updateTextureStyle(t){var e;const s=t._glTextures[this.CONTEXT_UID];s&&((t.mipmap===Ht.POW2||this.webGLVersion!==2)&&!t.isPowerOfTwo?s.mipmap=!1:s.mipmap=t.mipmap>=1,this.webGLVersion!==2&&!t.isPowerOfTwo?s.wrapMode=Zt.CLAMP:s.wrapMode=t.wrapMode,(e=t.resource)!=null&&e.style(this.renderer,t,s)||this.setStyle(t,s),s.dirtyStyleId=t.dirtyStyleId)}setStyle(t,e){const s=this.gl;if(e.mipmap&&t.mipmap!==Ht.ON_MANUAL&&s.generateMipmap(t.target),s.texParameteri(t.target,s.TEXTURE_WRAP_S,e.wrapMode),s.texParameteri(t.target,s.TEXTURE_WRAP_T,e.wrapMode),e.mipmap){s.texParameteri(t.target,s.TEXTURE_MIN_FILTER,t.scaleMode===Bt.LINEAR?s.LINEAR_MIPMAP_LINEAR:s.NEAREST_MIPMAP_NEAREST);const r=this.renderer.context.extensions.anisotropicFiltering;if(r&&t.anisotropicLevel>0&&t.scaleMode===Bt.LINEAR){const n=Math.min(t.anisotropicLevel,s.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT));s.texParameterf(t.target,r.TEXTURE_MAX_ANISOTROPY_EXT,n)}}else s.texParameteri(t.target,s.TEXTURE_MIN_FILTER,t.scaleMode===Bt.LINEAR?s.LINEAR:s.NEAREST);s.texParameteri(t.target,s.TEXTURE_MAG_FILTER,t.scaleMode===Bt.LINEAR?s.LINEAR:s.NEAREST)}destroy(){this.renderer=null}}Cn.extension={type:D.RendererSystem,name:"texture"},U.add(Cn);class Rn{constructor(t){this.renderer=t}contextChange(){this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(t){const{gl:e,CONTEXT_UID:s}=this,r=t._glTransformFeedbacks[s]||this.createGLTransformFeedback(t);e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,r)}unbind(){const{gl:t}=this;t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,null)}beginTransformFeedback(t,e){const{gl:s,renderer:r}=this;e&&r.shader.bind(e),s.beginTransformFeedback(t)}endTransformFeedback(){const{gl:t}=this;t.endTransformFeedback()}createGLTransformFeedback(t){const{gl:e,renderer:s,CONTEXT_UID:r}=this,n=e.createTransformFeedback();t._glTransformFeedbacks[r]=n,e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,n);for(let a=0;at in i?rf(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,Hi=(i,t)=>{for(var e in t||(t={}))nf.call(t,e)&&Eh(i,e,t[e]);if(Th)for(var e of Th(t))af.call(t,e)&&Eh(i,e,t[e]);return i};N.PREFER_ENV=be.WEBGL2,N.STRICT_TEXTURE_CACHE=!1,N.RENDER_OPTIONS=Hi(Hi(Hi(Hi({},Rs.defaultOptions),Cs.defaultOptions),Ds.defaultOptions),Ps.defaultOptions),Object.defineProperties(N,{WRAP_MODE:{get(){return X.defaultOptions.wrapMode},set(i){X.defaultOptions.wrapMode=i}},SCALE_MODE:{get(){return X.defaultOptions.scaleMode},set(i){X.defaultOptions.scaleMode=i}},MIPMAP_TEXTURES:{get(){return X.defaultOptions.mipmap},set(i){X.defaultOptions.mipmap=i}},ANISOTROPIC_LEVEL:{get(){return X.defaultOptions.anisotropicLevel},set(i){X.defaultOptions.anisotropicLevel=i}},FILTER_RESOLUTION:{get(){return Tt.defaultResolution},set(i){Tt.defaultResolution=i}},FILTER_MULTISAMPLE:{get(){return Tt.defaultMultisample},set(i){Tt.defaultMultisample=i}},SPRITE_MAX_TEXTURES:{get(){return Ee.defaultMaxTextures},set(i){Ee.defaultMaxTextures=i}},SPRITE_BATCH_SIZE:{get(){return Ee.defaultBatchSize},set(i){Ee.defaultBatchSize=i}},CAN_UPLOAD_SAME_BUFFER:{get(){return Ee.canUploadSameBuffer},set(i){Ee.canUploadSameBuffer=i}},GC_MODE:{get(){return Ae.defaultMode},set(i){Ae.defaultMode=i}},GC_MAX_IDLE:{get(){return Ae.defaultMaxIdle},set(i){Ae.defaultMaxIdle=i}},GC_MAX_CHECK_COUNT:{get(){return Ae.defaultCheckCountMax},set(i){Ae.defaultCheckCountMax=i}},PRECISION_VERTEX:{get(){return se.defaultVertexPrecision},set(i){se.defaultVertexPrecision=i}},PRECISION_FRAGMENT:{get(){return se.defaultFragmentPrecision},set(i){se.defaultFragmentPrecision=i}}});var pe=(i=>(i[i.INTERACTION=50]="INTERACTION",i[i.HIGH=25]="HIGH",i[i.NORMAL=0]="NORMAL",i[i.LOW=-25]="LOW",i[i.UTILITY=-50]="UTILITY",i))(pe||{});class In{constructor(t,e=null,s=0,r=!1){this.next=null,this.previous=null,this._destroyed=!1,this.fn=t,this.context=e,this.priority=s,this.once=r}match(t,e=null){return this.fn===t&&this.context===e}emit(t){this.fn&&(this.context?this.fn.call(this.context,t):this.fn(t));const e=this.next;return this.once&&this.destroy(!0),this._destroyed&&(this.next=null),e}connect(t){this.previous=t,t.next&&(t.next.previous=this),this.next=t.next,t.next=this}destroy(t=!1){this._destroyed=!0,this.fn=null,this.context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);const e=this.next;return this.next=t?null:e,this.previous=null,e}}const Ah=class Dt{constructor(){this.autoStart=!1,this.deltaTime=1,this.lastTime=-1,this.speed=1,this.started=!1,this._requestId=null,this._maxElapsedMS=100,this._minElapsedMS=0,this._protected=!1,this._lastFrame=-1,this._head=new In(null,null,1/0),this.deltaMS=1/Dt.targetFPMS,this.elapsedMS=1/Dt.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(t,e,s=pe.NORMAL){return this._addListener(new In(t,e,s))}addOnce(t,e,s=pe.NORMAL){return this._addListener(new In(t,e,s,!0))}_addListener(t){let e=this._head.next,s=this._head;if(!e)t.connect(s);else{for(;e;){if(t.priority>e.priority){t.connect(s);break}s=e,e=e.next}t.previous||t.connect(s)}return this._startIfPossible(),this}remove(t,e){let s=this._head.next;for(;s;)s.match(t,e)?s=s.destroy():s=s.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,e=this._head;for(;e=e.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let e;if(t>this.lastTime){if(e=this.elapsedMS=t-this.lastTime,e>this._maxElapsedMS&&(e=this._maxElapsedMS),e*=this.speed,this._minElapsedMS){const n=t-this._lastFrame|0;if(n{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?xt.shared:new xt,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}Pn.extension=D.Application,U.add(Pn);const wh=[];U.handleByList(D.Renderer,wh);function Sh(i){for(const t of wh)if(t.test(i))return new t(i);throw new Error("Unable to auto-detect a suitable renderer.")}var of=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,hf=`attribute vec2 aVertexPosition; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +uniform vec4 inputSize; +uniform vec4 outputFrame; + +vec4 filterVertexPosition( void ) +{ + vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy; + + return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0); +} + +vec2 filterTextureCoord( void ) +{ + return aVertexPosition * (outputFrame.zw * inputSize.zw); +} + +void main(void) +{ + gl_Position = filterVertexPosition(); + vTextureCoord = filterTextureCoord(); +} +`;const Ch=of,Mn=hf;class Dn{constructor(t){this.renderer=t}contextChange(t){let e;if(this.renderer.context.webGLVersion===1){const s=t.getParameter(t.FRAMEBUFFER_BINDING);t.bindFramebuffer(t.FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.FRAMEBUFFER,s)}else{const s=t.getParameter(t.DRAW_FRAMEBUFFER_BINDING);t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,s)}e>=ft.HIGH?this.multisample=ft.HIGH:e>=ft.MEDIUM?this.multisample=ft.MEDIUM:e>=ft.LOW?this.multisample=ft.LOW:this.multisample=ft.NONE}destroy(){}}Dn.extension={type:D.RendererSystem,name:"_multisample"},U.add(Dn);class lf{constructor(t){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}}class On{constructor(t){this.renderer=t,this.managedBuffers={},this.boundBufferBases={}}destroy(){this.renderer=null}contextChange(){this.disposeAll(!0),this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(t){const{gl:e,CONTEXT_UID:s}=this,r=t._glBuffers[s]||this.createGLBuffer(t);e.bindBuffer(t.type,r.buffer)}unbind(t){const{gl:e}=this;e.bindBuffer(t,null)}bindBufferBase(t,e){const{gl:s,CONTEXT_UID:r}=this;if(this.boundBufferBases[e]!==t){const n=t._glBuffers[r]||this.createGLBuffer(t);this.boundBufferBases[e]=t,s.bindBufferBase(s.UNIFORM_BUFFER,e,n.buffer)}}bindBufferRange(t,e,s){const{gl:r,CONTEXT_UID:n}=this;s=s||0;const a=t._glBuffers[n]||this.createGLBuffer(t);r.bindBufferRange(r.UNIFORM_BUFFER,e||0,a.buffer,s*256,256)}update(t){const{gl:e,CONTEXT_UID:s}=this,r=t._glBuffers[s]||this.createGLBuffer(t);if(t._updateID!==r.updateID)if(r.updateID=t._updateID,e.bindBuffer(t.type,r.buffer),r.byteLength>=t.data.byteLength)e.bufferSubData(t.type,0,t.data);else{const n=t.static?e.STATIC_DRAW:e.DYNAMIC_DRAW;r.byteLength=t.data.byteLength,e.bufferData(t.type,t.data,n)}}dispose(t,e){if(!this.managedBuffers[t.id])return;delete this.managedBuffers[t.id];const s=t._glBuffers[this.CONTEXT_UID],r=this.gl;t.disposeRunner.remove(this),s&&(e||r.deleteBuffer(s.buffer),delete t._glBuffers[this.CONTEXT_UID])}disposeAll(t){const e=Object.keys(this.managedBuffers);for(let s=0;se.resource).filter(e=>e).map(e=>e.load());return this._load=Promise.all(t).then(()=>{const{realWidth:e,realHeight:s}=this.items[0];return this.resize(e,s),this.update(),Promise.resolve(this)}),this._load}}class Rh extends Fn{constructor(t,e){const{width:s,height:r}=e||{};let n,a;Array.isArray(t)?(n=t,a=t.length):a=t,super(a,{width:s,height:r}),n&&this.initFromArray(n,e)}addBaseTextureAt(t,e){if(t.resource)this.addResourceAt(t.resource,e);else throw new Error("ArrayResource does not support RenderTexture");return this}bind(t){super.bind(t),t.target=Me.TEXTURE_2D_ARRAY}upload(t,e,s){const{length:r,itemDirtyIds:n,items:a}=this,{gl:o}=t;s.dirtyId<0&&o.texImage3D(o.TEXTURE_2D_ARRAY,0,s.internalFormat,this._width,this._height,r,0,e.format,s.type,null);for(let h=0;h0)if(t.resource)this.addResourceAt(t.resource,e);else throw new Error("CubeResource does not support copying of renderTexture.");else t.target=Me.TEXTURE_CUBE_MAP_POSITIVE_X+e,t.parentTextureArray=this.baseTexture,this.items[e]=t;return t.valid&&!this.valid&&this.resize(t.realWidth,t.realHeight),this.items[e]=t,this}upload(t,e,s){const r=this.itemDirtyIds;for(let n=0;n{if(this.url===null){t(this);return}try{const s=await N.ADAPTER.fetch(this.url,{mode:this.crossOrigin?"cors":"no-cors"});if(this.destroyed)return;const r=await s.blob();if(this.destroyed)return;const n=await createImageBitmap(r,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===At.UNPACK?"premultiply":"none"});if(this.destroyed){n.close();return}this.source=n,this.update(),t(this)}catch(s){if(this.destroyed)return;e(s),this.onError.emit(s)}}),this._load)}upload(t,e,s){return this.source instanceof ImageBitmap?(typeof this.alphaMode=="number"&&(e.alphaMode=this.alphaMode),super.upload(t,e,s)):(this.load(),!1)}dispose(){this.ownsImageBitmap&&this.source instanceof ImageBitmap&&this.source.close(),super.dispose(),this._load=null}static test(t){return!!globalThis.createImageBitmap&&typeof ImageBitmap!="undefined"&&(typeof t=="string"||t instanceof ImageBitmap)}static get EMPTY(){var t;return $e._EMPTY=(t=$e._EMPTY)!=null?t:N.ADAPTER.createCanvas(0,0),$e._EMPTY}}const Ln=class Tr extends fe{constructor(t,e){e=e||{},super(N.ADAPTER.createCanvas()),this._width=0,this._height=0,this.svg=t,this.scale=e.scale||1,this._overrideWidth=e.width,this._overrideHeight=e.height,this._resolve=null,this._crossorigin=e.crossorigin,this._load=null,e.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(t=>{if(this._resolve=()=>{this.update(),t(this)},Tr.SVG_XML.test(this.svg.trim())){if(!btoa)throw new Error("Your browser doesn't support base64 conversions.");this.svg=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(this.svg)))}`}this._loadSvg()}),this._load)}_loadSvg(){const t=new Image;fe.crossOrigin(t,this.svg,this._crossorigin),t.src=this.svg,t.onerror=e=>{this._resolve&&(t.onerror=null,this.onError.emit(e))},t.onload=()=>{if(!this._resolve)return;const e=t.width,s=t.height;if(!e||!s)throw new Error("The SVG image must have width and height defined (in pixels), canvas API needs them.");let r=e*this.scale,n=s*this.scale;(this._overrideWidth||this._overrideHeight)&&(r=this._overrideWidth||this._overrideHeight/s*e,n=this._overrideHeight||this._overrideWidth/e*s),r=Math.round(r),n=Math.round(n);const a=this.source;a.width=r,a.height=n,a._pixiId=`canvas_${Te()}`,a.getContext("2d").drawImage(t,0,0,e,s,0,0,r,n),this._resolve(),this._resolve=null}}static getSize(t){const e=Tr.SVG_SIZE.exec(t),s={};return e&&(s[e[1]]=Math.round(parseFloat(e[3])),s[e[5]]=Math.round(parseFloat(e[7]))),s}dispose(){super.dispose(),this._resolve=null,this._crossorigin=null}static test(t,e){return e==="svg"||typeof t=="string"&&t.startsWith("data:image/svg+xml")||typeof t=="string"&&Tr.SVG_XML.test(t)}};Ln.SVG_XML=/^(<\?xml[^?]+\?>)?\s*()]*-->)?\s*\]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;let Xi=Ln;const Un=class Aa extends fe{constructor(t,e){if(e=e||{},!(t instanceof HTMLVideoElement)){const s=document.createElement("video");e.autoLoad!==!1&&s.setAttribute("preload","auto"),e.playsinline!==!1&&(s.setAttribute("webkit-playsinline",""),s.setAttribute("playsinline","")),e.muted===!0&&(s.setAttribute("muted",""),s.muted=!0),e.loop===!0&&s.setAttribute("loop",""),e.autoPlay!==!1&&s.setAttribute("autoplay",""),typeof t=="string"&&(t=[t]);const r=t[0].src||t[0];fe.crossOrigin(s,r,e.crossorigin);for(let n=0;n{this.valid?e(this):(this._resolve=e,this._reject=s,t.load())}),this._load}_onError(t){this.source.removeEventListener("error",this._onError,!0),this.onError.emit(t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){const t=this.source;return!t.paused&&!t.ended&&this._isSourceReady()}_isSourceReady(){return this.source.readyState>2}_onPlayStart(){this.valid||this._onCanPlay(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0)}_onCanPlay(){const t=this.source;t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlay);const e=this.valid;this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0,!e&&this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&t.play()}dispose(){this._configureAutoUpdate();const t=this.source;t&&(t.removeEventListener("play",this._onPlayStart),t.removeEventListener("pause",this._onPlayStop),t.removeEventListener("seeked",this._onSeeked),t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlay),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.dispose()}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(t){t!==this._updateFPS&&(this._updateFPS=t,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.source.requestVideoFrameCallback?(this._isConnectedToTicker&&(xt.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),this._videoFrameRequestCallbackHandle===null&&(this._videoFrameRequestCallbackHandle=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(xt.shared.add(this.update,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(xt.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t,e){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement||Aa.TYPES.includes(e)}};Un.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],Un.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let kn=Un;Ei.push($e,un,Nn,kn,Xi,xs,Ph,Rh);class uf{constructor(){this._glTransformFeedbacks={},this.buffers=[],this.disposeRunner=new Pt("disposeTransformFeedback")}bindBuffer(t,e){this.buffers[t]=e}destroy(){this.disposeRunner.emit(this,!1)}}const cf="7.3.0";X.prototype.getDrawableSource=function(){const i=this.resource;return i?i.bitmap||i.source:null},Ni.prototype._canvasRenderTarget=null,L.prototype.patternCache=null,L.prototype.tintCache=null;let Os;function Mh(i){const t=N.ADAPTER.createCanvas(6,1),e=t.getContext("2d");return e.fillStyle=i,e.fillRect(0,0,6,1),t}function Gn(){if(typeof document=="undefined")return!1;if(Os!==void 0)return Os;const i=Mh("#ff00ff"),t=Mh("#ffff00"),e=N.ADAPTER.createCanvas(6,1).getContext("2d");e.globalCompositeOperation="multiply",e.drawImage(i,0,0),e.drawImage(t,2,0);const s=e.getImageData(2,0,1,1);if(!s)Os=!1;else{const r=s.data;Os=r[0]===255&&r[1]===0&&r[2]===0}return Os}function df(i=[]){return Gn()?(i[C.NORMAL]="source-over",i[C.ADD]="lighter",i[C.MULTIPLY]="multiply",i[C.SCREEN]="screen",i[C.OVERLAY]="overlay",i[C.DARKEN]="darken",i[C.LIGHTEN]="lighten",i[C.COLOR_DODGE]="color-dodge",i[C.COLOR_BURN]="color-burn",i[C.HARD_LIGHT]="hard-light",i[C.SOFT_LIGHT]="soft-light",i[C.DIFFERENCE]="difference",i[C.EXCLUSION]="exclusion",i[C.HUE]="hue",i[C.SATURATION]="saturation",i[C.COLOR]="color",i[C.LUMINOSITY]="luminosity"):(i[C.NORMAL]="source-over",i[C.ADD]="lighter",i[C.MULTIPLY]="source-over",i[C.SCREEN]="source-over",i[C.OVERLAY]="source-over",i[C.DARKEN]="source-over",i[C.LIGHTEN]="source-over",i[C.COLOR_DODGE]="source-over",i[C.COLOR_BURN]="source-over",i[C.HARD_LIGHT]="source-over",i[C.SOFT_LIGHT]="source-over",i[C.DIFFERENCE]="source-over",i[C.EXCLUSION]="source-over",i[C.HUE]="source-over",i[C.SATURATION]="source-over",i[C.COLOR]="source-over",i[C.LUMINOSITY]="source-over"),i[C.NORMAL_NPM]=i[C.NORMAL],i[C.ADD_NPM]=i[C.ADD],i[C.SCREEN_NPM]=i[C.SCREEN],i[C.SRC_IN]="source-in",i[C.SRC_OUT]="source-out",i[C.SRC_ATOP]="source-atop",i[C.DST_OVER]="destination-over",i[C.DST_IN]="destination-in",i[C.DST_OUT]="destination-out",i[C.DST_ATOP]="destination-atop",i[C.XOR]="xor",i[C.SUBTRACT]="source-over",i}const ff=new tt;class $n{constructor(t){this.activeResolution=1,this.smoothProperty="imageSmoothingEnabled",this.blendModes=df(),this._activeBlendMode=null,this._projTransform=null,this._outerBlend=!1,this.renderer=t}init(){const t=this.renderer.background.alpha<1;if(this.rootContext=this.renderer.view.getContext("2d",{alpha:t}),this.activeContext=this.rootContext,!this.rootContext.imageSmoothingEnabled){const e=this.rootContext;e.webkitImageSmoothingEnabled?this.smoothProperty="webkitImageSmoothingEnabled":e.mozImageSmoothingEnabled?this.smoothProperty="mozImageSmoothingEnabled":e.oImageSmoothingEnabled?this.smoothProperty="oImageSmoothingEnabled":e.msImageSmoothingEnabled&&(this.smoothProperty="msImageSmoothingEnabled")}}setContextTransform(t,e,s){let r=t;const n=this._projTransform,a=this.activeResolution;s=s||a,n&&(r=ff,r.copyFrom(t),r.prepend(n)),e?this.activeContext.setTransform(r.a*s,r.b*s,r.c*s,r.d*s,r.tx*a|0,r.ty*a|0):this.activeContext.setTransform(r.a*s,r.b*s,r.c*s,r.d*s,r.tx*a,r.ty*a)}clear(t,e){const{activeContext:s,renderer:r}=this,n=t?Y.shared.setValue(t):this.renderer.background.backgroundColor;s.clearRect(0,0,r.width,r.height),t&&(s.globalAlpha=e!=null?e:this.renderer.background.alpha,s.fillStyle=n.toHex(),s.fillRect(0,0,r.width,r.height),s.globalAlpha=1)}setBlendMode(t,e){const s=t===C.SRC_IN||t===C.SRC_OUT||t===C.DST_IN||t===C.DST_ATOP;!e&&s&&(t=C.NORMAL),this._activeBlendMode!==t&&(this._activeBlendMode=t,this._outerBlend=s,this.activeContext.globalCompositeOperation=this.blendModes[t])}resize(){this.smoothProperty&&(this.rootContext[this.smoothProperty]=X.defaultOptions.scaleMode===Bt.LINEAR)}invalidateBlendMode(){this._activeBlendMode=this.blendModes.indexOf(this.activeContext.globalCompositeOperation)}destroy(){this.renderer=null,this.rootContext=null,this.activeContext=null,this.smoothProperty=null}}$n.extension={type:D.CanvasRendererSystem,name:"canvasContext"},U.add($n);class Hn{constructor(t){this._foundShapes=[],this.renderer=t}pushMask(t){const e=this.renderer,s=t.maskObject||t;e.canvasContext.activeContext.save();const r=this._foundShapes;if(this.recursiveFindShapes(s,r),r.length>0){const n=e.canvasContext.activeContext;n.beginPath();for(let a=0;a0){u=0,d=h[0],f=h[1];for(let p=2;p+2=0;m-=2)e.lineTo(h[m],h[m+1])}l[p].shape.closeStroke&&e.closePath()}}h[0]===h[h.length-2]&&h[1]===h[h.length-1]&&e.closePath()}else if(o.type===it.RECT)e.rect(o.x,o.y,o.width,o.height),e.closePath();else if(o.type===it.CIRC)e.arc(o.x,o.y,o.radius,0,2*Math.PI),e.closePath();else if(o.type===it.ELIP){const h=o.width*2,l=o.height*2,u=o.x-h/2,c=o.y-l/2,d=.5522848,f=h/2*d,p=l/2*d,m=u+h,g=c+l,_=u+h/2,x=c+l/2;e.moveTo(u,x),e.bezierCurveTo(u,x-p,_-f,c,_,c),e.bezierCurveTo(_+f,c,m,x-p,m,x),e.bezierCurveTo(m,x+p,_+f,g,_,g),e.bezierCurveTo(_-f,g,u,x+p,u,x),e.closePath()}else if(o.type===it.RREC){const h=o.x,l=o.y,u=o.width,c=o.height;let d=o.radius;const f=Math.min(u,c)/2;d=d>f?f:d,e.moveTo(h,l+d),e.lineTo(h,l+c-d),e.quadraticCurveTo(h,l+c,h+d,l+c),e.lineTo(h+u-d,l+c),e.quadraticCurveTo(h+u,l+c,h+u,l+c-d),e.lineTo(h+u,l+d),e.quadraticCurveTo(h+u,l,h+u-d,l),e.lineTo(h+d,l),e.quadraticCurveTo(h,l,h,l+d),e.closePath()}}}popMask(t){t.canvasContext.activeContext.restore(),t.canvasContext.invalidateBlendMode()}destroy(){}}Hn.extension={type:D.CanvasRendererSystem,name:"mask"},U.add(Hn);class Vn{constructor(t){this.renderer=t}render(t,e){const s=this.renderer;if(!s.view)return;const r=s.canvasContext;let n,a,o,h;e&&(n=e.renderTexture,a=e.clear,o=e.transform,h=e.skipUpdateTransform),this.renderingToScreen=!n,s.emit("prerender");const l=s.resolution;n?(n=n.castToBaseTexture(),n._canvasRenderTarget||(n._canvasRenderTarget=new ys(n.width,n.height,n.resolution),n.resource=new Nn(n._canvasRenderTarget.canvas),n.valid=!0),r.activeContext=n._canvasRenderTarget.context,s.canvasContext.activeResolution=n._canvasRenderTarget.resolution):(r.activeContext=r.rootContext,r.activeResolution=l);const u=r.activeContext;if(r._projTransform=o||null,n||(this.lastObjectRendered=t),!h){const d=t.enableTempParent();t.updateTransform(),t.disableTempParent(d)}if(u.save(),u.setTransform(1,0,0,1,0,0),u.globalAlpha=1,r._activeBlendMode=C.NORMAL,r._outerBlend=!1,u.globalCompositeOperation=r.blendModes[C.NORMAL],a!=null?a:s.background.clearBeforeRender)if(this.renderingToScreen){u.clearRect(0,0,s.width,s.height);const d=s.background;d.alpha>0&&(u.globalAlpha=d.backgroundColor.alpha,u.fillStyle=d.backgroundColor.toHex(),u.fillRect(0,0,s.width,s.height),u.globalAlpha=1)}else n=n,n._canvasRenderTarget.clear(),n.clear.alpha>0&&(u.globalAlpha=n.clear.alpha,u.fillStyle=n.clear.toHex(),u.fillRect(0,0,n.realWidth,n.realHeight),u.globalAlpha=1);const c=r.activeContext;r.activeContext=u,t.renderCanvas(s),r.activeContext=c,u.restore(),r.activeResolution=l,r._projTransform=null,s.emit("postrender")}destroy(){this.lastObjectRendered=null,this.render=null}}Vn.extension={type:D.CanvasRendererSystem,name:"objectRenderer"},U.add(Vn);const{deprecation:pf}=Po,zi=class wa extends Sn{constructor(t){super(),this.type=li.CANVAS,this.rendererLogId="Canvas",t=Object.assign({},N.RENDER_OPTIONS,t);const e={runners:["init","destroy","contextChange","resolutionChange","reset","update","postrender","prerender","resize"],systems:wa.__systems,priority:["textureGenerator","background","_view","_plugin","startup","mask","canvasContext","objectRenderer"]};this.setup(e),"useContextAlpha"in t&&(t.backgroundAlpha=t.useContextAlpha===!1?1:t.backgroundAlpha),this._plugin.rendererPlugins=wa.__plugins,this.options=t,this.startup.run(this.options)}static test(){return!0}generateTexture(t,e){return this.textureGenerator.generateTexture(t,e)}reset(){}render(t,e){this.objectRenderer.render(t,e)}clear(){this.canvasContext.clear()}destroy(t){this.runners.destroy.items.reverse(),this.emitWithCustomOptions(this.runners.destroy,{_view:t}),super.destroy()}get plugins(){return this._plugin.plugins}resize(t,e){this._view.resizeView(t,e)}get width(){return this._view.element.width}get height(){return this._view.element.height}get resolution(){return this._view.resolution}set resolution(t){this._view.resolution=t,this.runners.resolutionChange.emit(t)}get autoDensity(){return this._view.autoDensity}get view(){return this._view.element}get screen(){return this._view.screen}get lastObjectRendered(){return this.objectRenderer.lastObjectRendered}get renderingToScreen(){return this.objectRenderer.renderingToScreen}get clearBeforeRender(){return this.background.clearBeforeRender}get blendModes(){return this.canvasContext.blendModes}get maskManager(){return pf("7.0.0","renderer.maskManager has been deprecated, please use renderer.mask instead"),this.mask}get refresh(){return!0}get rootContext(){return this.canvasContext.rootContext}get context(){return this.canvasContext.activeContext}get smoothProperty(){return this.canvasContext.smoothProperty}setBlendMode(t,e){this.canvasContext.setBlendMode(t,e)}invalidateBlendMode(){this.canvasContext.invalidateBlendMode()}setContextTransform(t,e,s){this.canvasContext.setContextTransform(t,e,s)}get backgroundColor(){return this.background.color}set backgroundColor(t){this.background.color=t}get backgroundAlpha(){return this.background.alpha}set backgroundAlpha(t){this.background.alpha=t}get preserveDrawingBuffer(){return!1}get useContextAlpha(){return!1}};zi.extension={type:D.Renderer,priority:0},zi.__plugins={},zi.__systems={};let Bs=zi;U.handleByMap(D.CanvasRendererPlugin,Bs.__plugins),U.handleByMap(D.CanvasRendererSystem,Bs.__systems),U.add(Bs);const gt={canvas:null,getTintedCanvas:(i,t)=>{const e=i.texture,s=Y.shared.setValue(t).toHex();e.tintCache=e.tintCache||{};const r=e.tintCache[s];let n;if(r){if(r.tintId===e._updateID)return e.tintCache[s];n=e.tintCache[s]}else n=N.ADAPTER.createCanvas();if(gt.tintMethod(e,t,n),n.tintId=e._updateID,gt.convertTintToImage&&n.toDataURL!==void 0){const a=new Image;a.src=n.toDataURL(),e.tintCache[s]=a}else e.tintCache[s]=n;return n},getTintedPattern:(i,t)=>{const e=Y.shared.setValue(t).toHex();i.patternCache=i.patternCache||{};let s=i.patternCache[e];return(s==null?void 0:s.tintId)===i._updateID||(gt.canvas||(gt.canvas=N.ADAPTER.createCanvas()),gt.tintMethod(i,t,gt.canvas),s=gt.canvas.getContext("2d").createPattern(gt.canvas,"repeat"),s.tintId=i._updateID,i.patternCache[e]=s),s},tintWithMultiply:(i,t,e)=>{const s=e.getContext("2d"),r=i._frame.clone(),n=i.baseTexture.resolution;r.x*=n,r.y*=n,r.width*=n,r.height*=n,e.width=Math.ceil(r.width),e.height=Math.ceil(r.height),s.save(),s.fillStyle=Y.shared.setValue(t).toHex(),s.fillRect(0,0,r.width,r.height),s.globalCompositeOperation="multiply";const a=i.baseTexture.getDrawableSource();s.drawImage(a,r.x,r.y,r.width,r.height,0,0,r.width,r.height),s.globalCompositeOperation="destination-atop",s.drawImage(a,r.x,r.y,r.width,r.height,0,0,r.width,r.height),s.restore()},tintWithOverlay:(i,t,e)=>{const s=e.getContext("2d"),r=i._frame.clone(),n=i.baseTexture.resolution;r.x*=n,r.y*=n,r.width*=n,r.height*=n,e.width=Math.ceil(r.width),e.height=Math.ceil(r.height),s.save(),s.globalCompositeOperation="copy",s.fillStyle=`#${`00000${(t|0).toString(16)}`.slice(-6)}`,s.fillRect(0,0,r.width,r.height),s.globalCompositeOperation="destination-atop",s.drawImage(i.baseTexture.getDrawableSource(),r.x,r.y,r.width,r.height,0,0,r.width,r.height),s.restore()},tintWithPerPixel:(i,t,e)=>{const s=e.getContext("2d"),r=i._frame.clone(),n=i.baseTexture.resolution;r.x*=n,r.y*=n,r.width*=n,r.height*=n,e.width=Math.ceil(r.width),e.height=Math.ceil(r.height),s.save(),s.globalCompositeOperation="copy",s.drawImage(i.baseTexture.getDrawableSource(),r.x,r.y,r.width,r.height,0,0,r.width,r.height),s.restore();const[a,o,h]=Y.shared.setValue(t).toArray(),l=s.getImageData(0,0,r.width,r.height),u=l.data;for(let c=0;cY.shared.setValue(i).round(gt.cacheStepsPerColorChannel).toNumber(),cacheStepsPerColorChannel:8,convertTintToImage:!1,canUseMultiply:Gn(),tintMethod:null};gt.tintMethod=gt.canUseMultiply?gt.tintWithMultiply:gt.tintWithPerPixel;class Fs{constructor(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.rect=null,this.updateID=-1}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}clear(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0}getRectangle(t){return this.minX>this.maxX||this.minY>this.maxY?z.EMPTY:(t=t||new z(0,0,1,1),t.x=this.minX,t.y=this.minY,t.width=this.maxX-this.minX,t.height=this.maxY-this.minY,t)}addPoint(t){this.minX=Math.min(this.minX,t.x),this.maxX=Math.max(this.maxX,t.x),this.minY=Math.min(this.minY,t.y),this.maxY=Math.max(this.maxY,t.y)}addPointMatrix(t,e){const{a:s,b:r,c:n,d:a,tx:o,ty:h}=t,l=s*e.x+n*e.y+o,u=r*e.x+a*e.y+h;this.minX=Math.min(this.minX,l),this.maxX=Math.max(this.maxX,l),this.minY=Math.min(this.minY,u),this.maxY=Math.max(this.maxY,u)}addQuad(t){let e=this.minX,s=this.minY,r=this.maxX,n=this.maxY,a=t[0],o=t[1];e=ar?a:r,n=o>n?o:n,a=t[2],o=t[3],e=ar?a:r,n=o>n?o:n,a=t[4],o=t[5],e=ar?a:r,n=o>n?o:n,a=t[6],o=t[7],e=ar?a:r,n=o>n?o:n,this.minX=e,this.minY=s,this.maxX=r,this.maxY=n}addFrame(t,e,s,r,n){this.addFrameMatrix(t.worldTransform,e,s,r,n)}addFrameMatrix(t,e,s,r,n){const a=t.a,o=t.b,h=t.c,l=t.d,u=t.tx,c=t.ty;let d=this.minX,f=this.minY,p=this.maxX,m=this.maxY,g=a*e+h*s+u,_=o*e+l*s+c;d=gp?g:p,m=_>m?_:m,g=a*r+h*s+u,_=o*r+l*s+c,d=gp?g:p,m=_>m?_:m,g=a*e+h*n+u,_=o*e+l*n+c,d=gp?g:p,m=_>m?_:m,g=a*r+h*n+u,_=o*r+l*n+c,d=gp?g:p,m=_>m?_:m,this.minX=d,this.minY=f,this.maxX=p,this.maxY=m}addVertexData(t,e,s){let r=this.minX,n=this.minY,a=this.maxX,o=this.maxY;for(let h=e;ha?l:a,o=u>o?u:o}this.minX=r,this.minY=n,this.maxX=a,this.maxY=o}addVertices(t,e,s,r){this.addVerticesMatrix(t.worldTransform,e,s,r)}addVerticesMatrix(t,e,s,r,n=0,a=n){const o=t.a,h=t.b,l=t.c,u=t.d,c=t.tx,d=t.ty;let f=this.minX,p=this.minY,m=this.maxX,g=this.maxY;for(let _=s;_r?t.maxX:r,this.maxY=t.maxY>n?t.maxY:n}addBoundsMask(t,e){const s=t.minX>e.minX?t.minX:e.minX,r=t.minY>e.minY?t.minY:e.minY,n=t.maxXl?n:l,this.maxY=a>u?a:u}}addBoundsMatrix(t,e){this.addFrameMatrix(e,t.minX,t.minY,t.maxX,t.maxY)}addBoundsArea(t,e){const s=t.minX>e.x?t.minX:e.x,r=t.minY>e.y?t.minY:e.y,n=t.maxXl?n:l,this.maxY=a>u?a:u}}pad(t=0,e=t){this.isEmpty()||(this.minX-=t,this.maxX+=t,this.minY-=e,this.maxY+=e)}addFramePad(t,e,s,r,n,a){t-=n,e-=a,s+=n,r+=a,this.minX=this.minXs?this.maxX:s,this.minY=this.minYr?this.maxY:r}}class ot extends Ye{constructor(){super(),this.tempDisplayObjectParent=null,this.transform=new Pi,this.alpha=1,this.visible=!0,this.renderable=!0,this.cullable=!1,this.cullArea=null,this.parent=null,this.worldAlpha=1,this._lastSortedIndex=0,this._zIndex=0,this.filterArea=null,this.filters=null,this._enabledFilters=null,this._bounds=new Fs,this._localBounds=null,this._boundsID=0,this._boundsRect=null,this._localBoundsRect=null,this._mask=null,this._maskRefCount=0,this._destroyed=!1,this.isSprite=!1,this.isMask=!1}static mixin(t){const e=Object.keys(t);for(let s=0;s1)for(let e=0;ethis.children.length)throw new Error(`${t}addChildAt: The index ${e} supplied is out of bounds ${this.children.length}`);return t.parent&&t.parent.removeChild(t),t.parent=this,this.sortDirty=!0,t.transform._parentID=-1,this.children.splice(e,0,t),this._boundsID++,this.onChildrenChange(e),t.emit("added",this),this.emit("childAdded",t,this,e),t}swapChildren(t,e){if(t===e)return;const s=this.getChildIndex(t),r=this.getChildIndex(e);this.children[s]=e,this.children[r]=t,this.onChildrenChange(s=this.children.length)throw new Error(`The index ${e} supplied is out of bounds ${this.children.length}`);const s=this.getChildIndex(t);Oe(this.children,s,1),this.children.splice(e,0,t),this.onChildrenChange(e)}getChildAt(t){if(t<0||t>=this.children.length)throw new Error(`getChildAt: Index (${t}) does not exist.`);return this.children[t]}removeChild(...t){if(t.length>1)for(let e=0;e0&&n<=r){a=this.children.splice(s,n);for(let o=0;o1&&this.children.sort(gf),this.sortDirty=!1}updateTransform(){this.sortableChildren&&this.sortDirty&&this.sortChildren(),this._boundsID++,this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha;for(let t=0,e=this.children.length;t0&&e.height>0))return;let s,r;this.cullArea?(s=this.cullArea,r=this.worldTransform):this._render!==Sa.prototype._render&&(s=this.getBounds(!0));const n=t.projection.transform;if(n&&(r?(r=mf.copyFrom(r),r.prepend(n)):r=n),s&&e.intersects(s,r))this._render(t);else if(this.cullArea)return;for(let a=0,o=this.children.length;a=r&&Ns.x=n&&Ns.y=r&&Ls.x=n&&Ls.y1?Wt.from(yf,vf,e):Wt.from(Bh,xf,e)}render(t){const e=this.renderer,s=this.quad;let r=s.vertices;r[0]=r[6]=t._width*-t.anchor.x,r[1]=r[3]=t._height*-t.anchor.y,r[2]=r[4]=t._width*(1-t.anchor.x),r[5]=r[7]=t._height*(1-t.anchor.y);const n=t.uvRespectAnchor?t.anchor.x:0,a=t.uvRespectAnchor?t.anchor.y:0;r=s.uvs,r[0]=r[6]=-n,r[1]=r[3]=-a,r[2]=r[4]=1-n,r[5]=r[7]=1-a,s.invalidate();const o=t._texture,h=o.baseTexture,l=h.alphaMode>0,u=t.tileTransform.localTransform,c=t.uvMatrix;let d=h.isPowerOfTwo&&o.frame.width===h.width&&o.frame.height===h.height;d&&(h._glTextures[e.CONTEXT_UID]?d=h.wrapMode!==Zt.CLAMP:h.wrapMode===Zt.CLAMP&&(h.wrapMode=Zt.REPEAT));const f=d?this.simpleShader:this.shader,p=o.width,m=o.height,g=t._width,_=t._height;Yi.set(u.a*p/g,u.b*p/_,u.c*m/g,u.d*m/_,u.tx/g,u.ty/_),Yi.invert(),d?Yi.prepend(c.mapCoord):(f.uniforms.uMapCoord=c.mapCoord.toArray(!0),f.uniforms.uClampFrame=c.uClampFrame,f.uniforms.uClampOffset=c.uClampOffset),f.uniforms.uTransform=Yi.toArray(!0),f.uniforms.uColor=Y.shared.setValue(t.tint).premultiply(t.worldAlpha,l).toArray(f.uniforms.uColor),f.uniforms.translationMatrix=t.transform.worldTransform.toArray(!0),f.uniforms.uSampler=o,e.shader.bind(f),e.geometry.bind(s),this.state.blendMode=$r(t.blendMode,l),e.state.set(this.state),e.geometry.draw(this.renderer.gl.TRIANGLES,6,0)}}jn.extension={name:"tilingSprite",type:D.RendererPlugin},U.add(jn);const qi=new tt,Us=new tt,ie=[new K,new K,new K,new K];Wi.prototype._renderCanvas=function(i){const t=this._texture;if(!t.baseTexture.valid)return;const e=i.canvasContext.activeContext,s=this.worldTransform,r=t.baseTexture,n=r.getDrawableSource(),a=r.resolution;if(this._textureID!==this._texture._updateID||this._cachedTint!==this.tintValue){this._textureID=this._texture._updateID;const d=new ys(t._frame.width,t._frame.height,a);this.tintValue!==16777215?(this._tintedCanvas=gt.getTintedCanvas(this,this.tintValue),d.context.drawImage(this._tintedCanvas,0,0)):d.context.drawImage(n,-t._frame.x*a,-t._frame.y*a),this._cachedTint=this.tintValue,this._canvasPattern=d.context.createPattern(d.canvas,"repeat")}e.globalAlpha=this.worldAlpha,i.canvasContext.setBlendMode(this.blendMode),this.tileTransform.updateLocalTransform();const o=this.tileTransform.localTransform,h=this._width,l=this._height;qi.identity(),Us.copyFrom(o),this.uvRespectAnchor||Us.translate(-this.anchor.x*h,-this.anchor.y*l),Us.scale(1/a,1/a),qi.prepend(Us),qi.prepend(s),i.canvasContext.setContextTransform(qi),e.fillStyle=this._canvasPattern;const u=this.anchor.x*-h,c=this.anchor.y*-l;ie[0].set(u,c),ie[1].set(u+h,c),ie[2].set(u+h,c+l),ie[3].set(u,c+l);for(let d=0;d<4;d++)Us.applyInverse(ie[d],ie[d]);e.beginPath(),e.moveTo(ie[0].x,ie[0].y);for(let d=1;d<4;d++)e.lineTo(ie[d].x,ie[d].y);e.closePath(),e.fill()};class Fh extends St{constructor(t=1500,e,s=16384,r=!1){super();const n=16384;s>n&&(s=n),this._properties=[!1,!0,!1,!1,!1],this._maxSize=t,this._batchSize=s,this._buffers=null,this._bufferUpdateIDs=[],this._updateID=0,this.interactiveChildren=!1,this.blendMode=C.NORMAL,this.autoResize=r,this.roundPixels=!0,this.baseTexture=null,this.setProperties(e),this._tintColor=new Y(0),this.tintRgb=new Float32Array(3),this.tint=16777215}setProperties(t){t&&(this._properties[0]="vertices"in t||"scale"in t?!!t.vertices||!!t.scale:this._properties[0],this._properties[1]="position"in t?!!t.position:this._properties[1],this._properties[2]="rotation"in t?!!t.rotation:this._properties[2],this._properties[3]="uvs"in t?!!t.uvs:this._properties[3],this._properties[4]="tint"in t||"alpha"in t?!!t.tint||!!t.alpha:this._properties[4])}updateTransform(){this.displayObjectUpdateTransform()}get tint(){return this._tintColor.value}set tint(t){this._tintColor.setValue(t),this._tintColor.toRgbArray(this.tintRgb)}render(t){!this.visible||this.worldAlpha<=0||!this.children.length||!this.renderable||(this.baseTexture||(this.baseTexture=this.children[0]._texture.baseTexture,this.baseTexture.valid||this.baseTexture.once("update",()=>this.onChildrenChange(0))),t.batch.setObjectRenderer(t.plugins.particle),t.plugins.particle.render(this))}onChildrenChange(t){const e=Math.floor(t/this._batchSize);for(;this._bufferUpdateIDs.lengths&&!t.autoResize&&(a=s);let o=t._buffers;o||(o=t._buffers=this.generateBuffers(t));const h=e[0]._texture.baseTexture,l=h.alphaMode>0;this.state.blendMode=$r(t.blendMode,l),n.state.set(this.state);const u=n.gl,c=t.worldTransform.copyTo(this.tempMatrix);c.prepend(n.globalUniforms.uniforms.projectionMatrix),this.shader.uniforms.translationMatrix=c.toArray(!0),this.shader.uniforms.uColor=Y.shared.setValue(t.tintRgb).premultiply(t.worldAlpha,l).toArray(this.shader.uniforms.uColor),this.shader.uniforms.uSampler=h,this.renderer.shader.bind(this.shader);let d=!1;for(let f=0,p=0;fr&&(m=r),p>=o.length&&o.push(this._generateOneMoreBuffer(t));const g=o[p];g.uploadDynamic(e,f,m);const _=t._bufferUpdateIDs[p]||0;d=d||g._updateID<_,d&&(g._updateID=t._updateID,g.uploadStatic(e,f,m)),n.geometry.bind(g.geometry),u.drawElements(u.TRIANGLES,m*6,u.UNSIGNED_SHORT,0)}}generateBuffers(t){const e=[],s=t._maxSize,r=t._batchSize,n=t._properties;for(let a=0;a0);r[a]=l,r[a+n]=l,r[a+n*2]=l,r[a+n*3]=l,a+=n*4}}destroy(){super.destroy(),this.shader&&(this.shader.destroy(),this.shader=null),this.tempMatrix=null}}Xn.extension={name:"particle",type:D.RendererPlugin},U.add(Xn),Fh.prototype.renderCanvas=function(i){if(!this.visible||this.worldAlpha<=0||!this.children.length||!this.renderable)return;const t=i.canvasContext.activeContext,e=this.worldTransform;let s=!0,r=0,n=0,a=0,o=0;i.canvasContext.setBlendMode(this.blendMode),t.globalAlpha=this.worldAlpha,this.displayObjectUpdateTransform();for(let h=0;h(i[i.LINEAR_VERTICAL=0]="LINEAR_VERTICAL",i[i.LINEAR_HORIZONTAL=1]="LINEAR_HORIZONTAL",i))(ks||{});const Ki={willReadFrequently:!0},re=class G{static get experimentalLetterSpacingSupported(){let t=G._experimentalLetterSpacingSupported;if(t!==void 0){const e=N.ADAPTER.getCanvasRenderingContext2D().prototype;t=G._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,s,r,n,a,o,h,l){this.text=t,this.style=e,this.width=s,this.height=r,this.lines=n,this.lineWidths=a,this.lineHeight=o,this.maxLineWidth=h,this.fontProperties=l}static measureText(t,e,s,r=G._canvas){s=s==null?e.wordWrap:s;const n=e.toFontString(),a=G.measureFont(n);a.fontSize===0&&(a.fontSize=e.fontSize,a.ascent=e.fontSize);const o=r.getContext("2d",Ki);o.font=n;const h=(s?G.wordWrap(t,e,r):t).split(/(?:\r\n|\r|\n)/),l=new Array(h.length);let u=0;for(let p=0;p0&&(r?n-=e:n+=(G.graphemeSegmenter(t).length-1)*e),n}static wordWrap(t,e,s=G._canvas){const r=s.getContext("2d",Ki);let n=0,a="",o="";const h=Object.create(null),{letterSpacing:l,whiteSpace:u}=e,c=G.collapseSpaces(u),d=G.collapseNewlines(u);let f=!c;const p=e.wordWrapWidth+l,m=G.tokenize(t);for(let g=0;gp)if(a!==""&&(o+=G.addLine(a),a="",n=0),G.canBreakWords(_,e.breakWords)){const v=G.wordWrapSplit(_);for(let b=0;bp&&(o+=G.addLine(a),f=!1,a="",n=0),a+=T,n+=A}}else{a.length>0&&(o+=G.addLine(a),a="",n=0);const v=g===m.length-1;o+=G.addLine(_,!v),f=!1,a="",n=0}else x+n>p&&(f=!1,o+=G.addLine(a),a="",n=0),(a.length>0||!G.isBreakingSpace(_)||f)&&(a+=_,n+=x)}return o+=G.addLine(a,!1),o}static addLine(t,e=!0){return t=G.trimRight(t),t=e?`${t} +`:t,t}static getFromCache(t,e,s,r){let n=s[t];return typeof n!="number"&&(n=G._measureText(t,e,r)+e,s[t]=n),n}static collapseSpaces(t){return t==="normal"||t==="pre-line"}static collapseNewlines(t){return t==="normal"}static trimRight(t){if(typeof t!="string")return"";for(let e=t.length-1;e>=0;e--){const s=t[e];if(!G.isBreakingSpace(s))break;t=t.slice(0,-1)}return t}static isNewline(t){return typeof t!="string"?!1:G._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:G._breakingSpaces.includes(t.charCodeAt(0))}static tokenize(t){const e=[];let s="";if(typeof t!="string")return e;for(let r=0;ro;--d){for(let m=0;m{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const i=new Intl.Segmenter;return t=>[...i.segment(t)].map(e=>e.segment)}return i=>[...i]})(),re.experimentalLetterSpacing=!1,re._fonts={},re._newlines=[10,13],re._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];let me=re;const Af=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],Lh=class ai{constructor(t){this.styleID=0,this.reset(),Wn(this,t,t)}clone(){const t={};return Wn(t,this,ai.defaultStyle),new ai(t)}reset(){Wn(this,ai.defaultStyle,ai.defaultStyle)}get align(){return this._align}set align(t){this._align!==t&&(this._align=t,this.styleID++)}get breakWords(){return this._breakWords}set breakWords(t){this._breakWords!==t&&(this._breakWords=t,this.styleID++)}get dropShadow(){return this._dropShadow}set dropShadow(t){this._dropShadow!==t&&(this._dropShadow=t,this.styleID++)}get dropShadowAlpha(){return this._dropShadowAlpha}set dropShadowAlpha(t){this._dropShadowAlpha!==t&&(this._dropShadowAlpha=t,this.styleID++)}get dropShadowAngle(){return this._dropShadowAngle}set dropShadowAngle(t){this._dropShadowAngle!==t&&(this._dropShadowAngle=t,this.styleID++)}get dropShadowBlur(){return this._dropShadowBlur}set dropShadowBlur(t){this._dropShadowBlur!==t&&(this._dropShadowBlur=t,this.styleID++)}get dropShadowColor(){return this._dropShadowColor}set dropShadowColor(t){const e=zn(t);this._dropShadowColor!==e&&(this._dropShadowColor=e,this.styleID++)}get dropShadowDistance(){return this._dropShadowDistance}set dropShadowDistance(t){this._dropShadowDistance!==t&&(this._dropShadowDistance=t,this.styleID++)}get fill(){return this._fill}set fill(t){const e=zn(t);this._fill!==e&&(this._fill=e,this.styleID++)}get fillGradientType(){return this._fillGradientType}set fillGradientType(t){this._fillGradientType!==t&&(this._fillGradientType=t,this.styleID++)}get fillGradientStops(){return this._fillGradientStops}set fillGradientStops(t){wf(this._fillGradientStops,t)||(this._fillGradientStops=t,this.styleID++)}get fontFamily(){return this._fontFamily}set fontFamily(t){this.fontFamily!==t&&(this._fontFamily=t,this.styleID++)}get fontSize(){return this._fontSize}set fontSize(t){this._fontSize!==t&&(this._fontSize=t,this.styleID++)}get fontStyle(){return this._fontStyle}set fontStyle(t){this._fontStyle!==t&&(this._fontStyle=t,this.styleID++)}get fontVariant(){return this._fontVariant}set fontVariant(t){this._fontVariant!==t&&(this._fontVariant=t,this.styleID++)}get fontWeight(){return this._fontWeight}set fontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.styleID++)}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing!==t&&(this._letterSpacing=t,this.styleID++)}get lineHeight(){return this._lineHeight}set lineHeight(t){this._lineHeight!==t&&(this._lineHeight=t,this.styleID++)}get leading(){return this._leading}set leading(t){this._leading!==t&&(this._leading=t,this.styleID++)}get lineJoin(){return this._lineJoin}set lineJoin(t){this._lineJoin!==t&&(this._lineJoin=t,this.styleID++)}get miterLimit(){return this._miterLimit}set miterLimit(t){this._miterLimit!==t&&(this._miterLimit=t,this.styleID++)}get padding(){return this._padding}set padding(t){this._padding!==t&&(this._padding=t,this.styleID++)}get stroke(){return this._stroke}set stroke(t){const e=zn(t);this._stroke!==e&&(this._stroke=e,this.styleID++)}get strokeThickness(){return this._strokeThickness}set strokeThickness(t){this._strokeThickness!==t&&(this._strokeThickness=t,this.styleID++)}get textBaseline(){return this._textBaseline}set textBaseline(t){this._textBaseline!==t&&(this._textBaseline=t,this.styleID++)}get trim(){return this._trim}set trim(t){this._trim!==t&&(this._trim=t,this.styleID++)}get whiteSpace(){return this._whiteSpace}set whiteSpace(t){this._whiteSpace!==t&&(this._whiteSpace=t,this.styleID++)}get wordWrap(){return this._wordWrap}set wordWrap(t){this._wordWrap!==t&&(this._wordWrap=t,this.styleID++)}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(t){this._wordWrapWidth!==t&&(this._wordWrapWidth=t,this.styleID++)}toFontString(){const t=typeof this.fontSize=="number"?`${this.fontSize}px`:this.fontSize;let e=this.fontFamily;Array.isArray(this.fontFamily)||(e=this.fontFamily.split(","));for(let s=e.length-1;s>=0;s--){let r=e[s].trim();!/([\"\'])[^\'\"]+\1/.test(r)&&!Af.includes(r)&&(r=`"${r}"`),e[s]=r}return`${this.fontStyle} ${this.fontVariant} ${this.fontWeight} ${t} ${e.join(",")}`}};Lh.defaultStyle={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fillGradientType:ks.LINEAR_VERTICAL,fillGradientStops:[],fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",leading:0,letterSpacing:0,lineHeight:0,lineJoin:"miter",miterLimit:10,padding:0,stroke:"black",strokeThickness:0,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100};let ge=Lh;function zn(i){const t=Y.shared,e=s=>{const r=t.setValue(s);return r.alpha===1?r.toHex():r.toRgbaString()};return Array.isArray(i)?i.map(e):e(i)}function wf(i,t){if(!Array.isArray(i)||!Array.isArray(t)||i.length!==t.length)return!1;for(let e=0;e0&&p>m&&(g=(m+p)/2);const _=m+d,x=s.lineHeight*(f+1);let v=_;f+1=e&&(a=i-o-1),h=h.replace("%value%",t[a].toString()),r+=h,r+=` +`}return s=s.replace("%blur%",r),s=s.replace("%size%",i.toString()),s}const Df=` + attribute vec2 aVertexPosition; + + uniform mat3 projectionMatrix; + + uniform float strength; + + varying vec2 vBlurTexCoords[%size%]; + + uniform vec4 inputSize; + uniform vec4 outputFrame; + + vec4 filterVertexPosition( void ) + { + vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy; + + return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0); + } + + vec2 filterTextureCoord( void ) + { + return aVertexPosition * (outputFrame.zw * inputSize.zw); + } + + void main(void) + { + gl_Position = filterVertexPosition(); + + vec2 textureCoord = filterTextureCoord(); + %blur% + }`;function Of(i,t){const e=Math.ceil(i/2);let s=Df,r="",n;t?n="vBlurTexCoords[%index%] = textureCoord + vec2(%sampleIndex% * strength, 0.0);":n="vBlurTexCoords[%index%] = textureCoord + vec2(0.0, %sampleIndex% * strength);";for(let a=0;a 0.0) { + c.rgb /= c.a; + } + + vec4 result; + + result.r = (m[0] * c.r); + result.r += (m[1] * c.g); + result.r += (m[2] * c.b); + result.r += (m[3] * c.a); + result.r += m[4]; + + result.g = (m[5] * c.r); + result.g += (m[6] * c.g); + result.g += (m[7] * c.b); + result.g += (m[8] * c.a); + result.g += m[9]; + + result.b = (m[10] * c.r); + result.b += (m[11] * c.g); + result.b += (m[12] * c.b); + result.b += (m[13] * c.a); + result.b += m[14]; + + result.a = (m[15] * c.r); + result.a += (m[16] * c.g); + result.a += (m[17] * c.b); + result.a += (m[18] * c.a); + result.a += m[19]; + + vec3 rgb = mix(c.rgb, result.rgb, uAlpha); + + // Premultiply alpha again. + rgb *= result.a; + + gl_FragColor = vec4(rgb, result.a); +} +`;class Ji extends Tt{constructor(){const t={m:new Float32Array([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0]),uAlpha:1};super(Mn,Bf,t),this.alpha=1}_loadMatrix(t,e=!1){let s=t;e&&(this._multiply(s,this.uniforms.m,t),s=this._colorMatrix(s)),this.uniforms.m=s}_multiply(t,e,s){return t[0]=e[0]*s[0]+e[1]*s[5]+e[2]*s[10]+e[3]*s[15],t[1]=e[0]*s[1]+e[1]*s[6]+e[2]*s[11]+e[3]*s[16],t[2]=e[0]*s[2]+e[1]*s[7]+e[2]*s[12]+e[3]*s[17],t[3]=e[0]*s[3]+e[1]*s[8]+e[2]*s[13]+e[3]*s[18],t[4]=e[0]*s[4]+e[1]*s[9]+e[2]*s[14]+e[3]*s[19]+e[4],t[5]=e[5]*s[0]+e[6]*s[5]+e[7]*s[10]+e[8]*s[15],t[6]=e[5]*s[1]+e[6]*s[6]+e[7]*s[11]+e[8]*s[16],t[7]=e[5]*s[2]+e[6]*s[7]+e[7]*s[12]+e[8]*s[17],t[8]=e[5]*s[3]+e[6]*s[8]+e[7]*s[13]+e[8]*s[18],t[9]=e[5]*s[4]+e[6]*s[9]+e[7]*s[14]+e[8]*s[19]+e[9],t[10]=e[10]*s[0]+e[11]*s[5]+e[12]*s[10]+e[13]*s[15],t[11]=e[10]*s[1]+e[11]*s[6]+e[12]*s[11]+e[13]*s[16],t[12]=e[10]*s[2]+e[11]*s[7]+e[12]*s[12]+e[13]*s[17],t[13]=e[10]*s[3]+e[11]*s[8]+e[12]*s[13]+e[13]*s[18],t[14]=e[10]*s[4]+e[11]*s[9]+e[12]*s[14]+e[13]*s[19]+e[14],t[15]=e[15]*s[0]+e[16]*s[5]+e[17]*s[10]+e[18]*s[15],t[16]=e[15]*s[1]+e[16]*s[6]+e[17]*s[11]+e[18]*s[16],t[17]=e[15]*s[2]+e[16]*s[7]+e[17]*s[12]+e[18]*s[17],t[18]=e[15]*s[3]+e[16]*s[8]+e[17]*s[13]+e[18]*s[18],t[19]=e[15]*s[4]+e[16]*s[9]+e[17]*s[14]+e[18]*s[19]+e[19],t}_colorMatrix(t){const e=new Float32Array(t);return e[4]/=255,e[9]/=255,e[14]/=255,e[19]/=255,e}brightness(t,e){const s=[t,0,0,0,0,0,t,0,0,0,0,0,t,0,0,0,0,0,1,0];this._loadMatrix(s,e)}tint(t,e){const[s,r,n]=Y.shared.setValue(t).toArray(),a=[s,0,0,0,0,0,r,0,0,0,0,0,n,0,0,0,0,0,1,0];this._loadMatrix(a,e)}greyscale(t,e){const s=[t,t,t,0,0,t,t,t,0,0,t,t,t,0,0,0,0,0,1,0];this._loadMatrix(s,e)}blackAndWhite(t){const e=[.3,.6,.1,0,0,.3,.6,.1,0,0,.3,.6,.1,0,0,0,0,0,1,0];this._loadMatrix(e,t)}hue(t,e){t=(t||0)/180*Math.PI;const s=Math.cos(t),r=Math.sin(t),n=Math.sqrt,a=1/3,o=n(a),h=s+(1-s)*a,l=a*(1-s)-o*r,u=a*(1-s)+o*r,c=a*(1-s)+o*r,d=s+a*(1-s),f=a*(1-s)-o*r,p=a*(1-s)-o*r,m=a*(1-s)+o*r,g=s+a*(1-s),_=[h,l,u,0,0,c,d,f,0,0,p,m,g,0,0,0,0,0,1,0];this._loadMatrix(_,e)}contrast(t,e){const s=(t||0)+1,r=-.5*(s-1),n=[s,0,0,0,r,0,s,0,0,r,0,0,s,0,r,0,0,0,1,0];this._loadMatrix(n,e)}saturate(t=0,e){const s=t*2/3+1,r=(s-1)*-.5,n=[s,r,r,0,0,r,s,r,0,0,r,r,s,0,0,0,0,0,1,0];this._loadMatrix(n,e)}desaturate(){this.saturate(-1)}negative(t){const e=[-1,0,0,1,0,0,-1,0,1,0,0,0,-1,1,0,0,0,0,1,0];this._loadMatrix(e,t)}sepia(t){const e=[.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0];this._loadMatrix(e,t)}technicolor(t){const e=[1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0];this._loadMatrix(e,t)}polaroid(t){const e=[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0];this._loadMatrix(e,t)}toBGR(t){const e=[0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0];this._loadMatrix(e,t)}kodachrome(t){const e=[1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0];this._loadMatrix(e,t)}browni(t){const e=[.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0];this._loadMatrix(e,t)}vintage(t){const e=[.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0];this._loadMatrix(e,t)}colorTone(t,e,s,r,n){t=t||.2,e=e||.15,s=s||16770432,r=r||3375104;const a=Y.shared,[o,h,l]=a.setValue(s).toArray(),[u,c,d]=a.setValue(r).toArray(),f=[.3,.59,.11,0,0,o,h,l,t,0,u,c,d,e,0,o-u,h-c,l-d,0,0];this._loadMatrix(f,n)}night(t,e){t=t||.1;const s=[t*-2,-t,0,0,0,-t,0,t,0,0,0,t,t*2,0,0,0,0,0,1,0];this._loadMatrix(s,e)}predator(t,e){const s=[11.224130630493164*t,-4.794486999511719*t,-2.8746118545532227*t,0*t,.40342438220977783*t,-3.6330697536468506*t,9.193157196044922*t,-2.951810836791992*t,0*t,-1.316135048866272*t,-3.2184197902679443*t,-4.2375030517578125*t,7.476448059082031*t,0*t,.8044459223747253*t,0,0,0,1,0];this._loadMatrix(s,e)}lsd(t){const e=[2,-.4,.5,0,0,-.5,2,-.4,0,0,-.4,-.5,3,0,0,0,0,0,1,0];this._loadMatrix(e,t)}reset(){const t=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];this._loadMatrix(t,!1)}get matrix(){return this.uniforms.m}set matrix(t){this.uniforms.m=t}get alpha(){return this.uniforms.uAlpha}set alpha(t){this.uniforms.uAlpha=t}}Ji.prototype.grayscale=Ji.prototype.greyscale;var Ff=`varying vec2 vFilterCoord; +varying vec2 vTextureCoord; + +uniform vec2 scale; +uniform mat2 rotation; +uniform sampler2D uSampler; +uniform sampler2D mapSampler; + +uniform highp vec4 inputSize; +uniform vec4 inputClamp; + +void main(void) +{ + vec4 map = texture2D(mapSampler, vFilterCoord); + + map -= 0.5; + map.xy = scale * inputSize.zw * (rotation * map.xy); + + gl_FragColor = texture2D(uSampler, clamp(vec2(vTextureCoord.x + map.x, vTextureCoord.y + map.y), inputClamp.xy, inputClamp.zw)); +} +`,Nf=`attribute vec2 aVertexPosition; + +uniform mat3 projectionMatrix; +uniform mat3 filterMatrix; + +varying vec2 vTextureCoord; +varying vec2 vFilterCoord; + +uniform vec4 inputSize; +uniform vec4 outputFrame; + +vec4 filterVertexPosition( void ) +{ + vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy; + + return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0); +} + +vec2 filterTextureCoord( void ) +{ + return aVertexPosition * (outputFrame.zw * inputSize.zw); +} + +void main(void) +{ + gl_Position = filterVertexPosition(); + vTextureCoord = filterTextureCoord(); + vFilterCoord = ( filterMatrix * vec3( vTextureCoord, 1.0) ).xy; +} +`;class Hh extends Tt{constructor(t,e){const s=new tt;t.renderable=!1,super(Nf,Ff,{mapSampler:t._texture,filterMatrix:s,scale:{x:1,y:1},rotation:new Float32Array([1,0,0,1])}),this.maskSprite=t,this.maskMatrix=s,e==null&&(e=20),this.scale=new K(e,e)}apply(t,e,s,r){this.uniforms.filterMatrix=t.calculateSpriteMatrix(this.maskMatrix,this.maskSprite),this.uniforms.scale.x=this.scale.x,this.uniforms.scale.y=this.scale.y;const n=this.maskSprite.worldTransform,a=Math.sqrt(n.a*n.a+n.b*n.b),o=Math.sqrt(n.c*n.c+n.d*n.d);a!==0&&o!==0&&(this.uniforms.rotation[0]=n.a/a,this.uniforms.rotation[1]=n.b/a,this.uniforms.rotation[2]=n.c/o,this.uniforms.rotation[3]=n.d/o),t.applyFilter(this,e,s,r)}get map(){return this.uniforms.mapSampler}set map(t){this.uniforms.mapSampler=t}}var Lf=`varying vec2 v_rgbNW; +varying vec2 v_rgbNE; +varying vec2 v_rgbSW; +varying vec2 v_rgbSE; +varying vec2 v_rgbM; + +varying vec2 vFragCoord; +uniform sampler2D uSampler; +uniform highp vec4 inputSize; + + +/** + Basic FXAA implementation based on the code on geeks3d.com with the + modification that the texture2DLod stuff was removed since it's + unsupported by WebGL. + + -- + + From: + https://github.com/mitsuhiko/webgl-meincraft + + Copyright (c) 2011 by Armin Ronacher. + + Some rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + * The names of the contributors may not be used to endorse or + promote products derived from this software without specific + prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FXAA_REDUCE_MIN +#define FXAA_REDUCE_MIN (1.0/ 128.0) +#endif +#ifndef FXAA_REDUCE_MUL +#define FXAA_REDUCE_MUL (1.0 / 8.0) +#endif +#ifndef FXAA_SPAN_MAX +#define FXAA_SPAN_MAX 8.0 +#endif + +//optimized version for mobile, where dependent +//texture reads can be a bottleneck +vec4 fxaa(sampler2D tex, vec2 fragCoord, vec2 inverseVP, + vec2 v_rgbNW, vec2 v_rgbNE, + vec2 v_rgbSW, vec2 v_rgbSE, + vec2 v_rgbM) { + vec4 color; + vec3 rgbNW = texture2D(tex, v_rgbNW).xyz; + vec3 rgbNE = texture2D(tex, v_rgbNE).xyz; + vec3 rgbSW = texture2D(tex, v_rgbSW).xyz; + vec3 rgbSE = texture2D(tex, v_rgbSE).xyz; + vec4 texColor = texture2D(tex, v_rgbM); + vec3 rgbM = texColor.xyz; + vec3 luma = vec3(0.299, 0.587, 0.114); + float lumaNW = dot(rgbNW, luma); + float lumaNE = dot(rgbNE, luma); + float lumaSW = dot(rgbSW, luma); + float lumaSE = dot(rgbSE, luma); + float lumaM = dot(rgbM, luma); + float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE))); + float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE))); + + mediump vec2 dir; + dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE)); + dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE)); + + float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) * + (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN); + + float rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce); + dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX), + max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX), + dir * rcpDirMin)) * inverseVP; + + vec3 rgbA = 0.5 * ( + texture2D(tex, fragCoord * inverseVP + dir * (1.0 / 3.0 - 0.5)).xyz + + texture2D(tex, fragCoord * inverseVP + dir * (2.0 / 3.0 - 0.5)).xyz); + vec3 rgbB = rgbA * 0.5 + 0.25 * ( + texture2D(tex, fragCoord * inverseVP + dir * -0.5).xyz + + texture2D(tex, fragCoord * inverseVP + dir * 0.5).xyz); + + float lumaB = dot(rgbB, luma); + if ((lumaB < lumaMin) || (lumaB > lumaMax)) + color = vec4(rgbA, texColor.a); + else + color = vec4(rgbB, texColor.a); + return color; +} + +void main() { + + vec4 color; + + color = fxaa(uSampler, vFragCoord, inputSize.zw, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM); + + gl_FragColor = color; +} +`,Uf=` +attribute vec2 aVertexPosition; + +uniform mat3 projectionMatrix; + +varying vec2 v_rgbNW; +varying vec2 v_rgbNE; +varying vec2 v_rgbSW; +varying vec2 v_rgbSE; +varying vec2 v_rgbM; + +varying vec2 vFragCoord; + +uniform vec4 inputSize; +uniform vec4 outputFrame; + +vec4 filterVertexPosition( void ) +{ + vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy; + + return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0); +} + +void texcoords(vec2 fragCoord, vec2 inverseVP, + out vec2 v_rgbNW, out vec2 v_rgbNE, + out vec2 v_rgbSW, out vec2 v_rgbSE, + out vec2 v_rgbM) { + v_rgbNW = (fragCoord + vec2(-1.0, -1.0)) * inverseVP; + v_rgbNE = (fragCoord + vec2(1.0, -1.0)) * inverseVP; + v_rgbSW = (fragCoord + vec2(-1.0, 1.0)) * inverseVP; + v_rgbSE = (fragCoord + vec2(1.0, 1.0)) * inverseVP; + v_rgbM = vec2(fragCoord * inverseVP); +} + +void main(void) { + + gl_Position = filterVertexPosition(); + + vFragCoord = aVertexPosition * outputFrame.zw; + + texcoords(vFragCoord, inputSize.zw, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM); +} +`;class Vh extends Tt{constructor(){super(Uf,Lf)}}var kf=`precision highp float; + +varying vec2 vTextureCoord; +varying vec4 vColor; + +uniform float uNoise; +uniform float uSeed; +uniform sampler2D uSampler; + +float rand(vec2 co) +{ + return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453); +} + +void main() +{ + vec4 color = texture2D(uSampler, vTextureCoord); + float randomValue = rand(gl_FragCoord.xy * uSeed); + float diff = (randomValue - 0.5) * uNoise; + + // Un-premultiply alpha before applying the color matrix. See issue #3539. + if (color.a > 0.0) { + color.rgb /= color.a; + } + + color.r += diff; + color.g += diff; + color.b += diff; + + // Premultiply alpha again. + color.rgb *= color.a; + + gl_FragColor = color; +} +`;class jh extends Tt{constructor(t=.5,e=Math.random()){super(Mn,kf,{uNoise:0,uSeed:0}),this.noise=t,this.seed=e}get noise(){return this.uniforms.uNoise}set noise(t){this.uniforms.uNoise=t}get seed(){return this.uniforms.uSeed}set seed(t){this.uniforms.uSeed=t}}const Yn={AlphaFilter:Gh,BlurFilter:$h,BlurFilterPass:Qi,ColorMatrixFilter:Ji,DisplacementFilter:Hh,FXAAFilter:Vh,NoiseFilter:jh};Object.entries(Yn).forEach(([i,t])=>{Object.defineProperty(Yn,i,{get(){return ro("7.1.0",`filters.${i} has moved to ${i}`),t}})});let Gf=class{constructor(){this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this.tickerAdded=!1,this._pauseUpdate=!0}init(t){this.removeTickerListener(),this.events=t,this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this.tickerAdded=!1,this._pauseUpdate=!0}get pauseUpdate(){return this._pauseUpdate}set pauseUpdate(t){this._pauseUpdate=t}addTickerListener(){this.tickerAdded||!this.domElement||(xt.system.add(this.tickerUpdate,this,pe.INTERACTION),this.tickerAdded=!0)}removeTickerListener(){this.tickerAdded&&(xt.system.remove(this.tickerUpdate,this),this.tickerAdded=!1)}pointerMoved(){this._didMove=!0}update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove){this._didMove=!1;return}const t=this.events.rootPointerEvent;this.events.supportsTouchEvents&&t.pointerType==="touch"||globalThis.document.dispatchEvent(new PointerEvent("pointermove",{clientX:t.clientX,clientY:t.clientY}))}tickerUpdate(t){this._deltaTime+=t,!(this._deltaTimes.priority-r.priority)}dispatchEvent(t,e){t.propagationStopped=!1,t.propagationImmediatelyStopped=!1,this.propagate(t,e),this.dispatch.emit(e||t.type,t)}mapEvent(t){if(!this.rootTarget)return;const e=this.mappingTable[t.type];if(e)for(let s=0,r=e.length;s=0;r--)if(t.currentTarget=s[r],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,e,s=this._allInteractiveElements){if(s.length===0)return;t.eventPhase=t.BUBBLING_PHASE;const r=Array.isArray(e)?e:[e];for(let n=s.length-1;n>=0;n--)r.forEach(a=>{t.currentTarget=s[n],this.notifyTarget(t,a)})}propagationPath(t){const e=[t];for(let s=0;s<$f&&t!==this.rootTarget;s++){if(!t.parent)throw new Error("Cannot find propagation path to disconnected target");e.push(t.parent),t=t.parent}return e.reverse(),e}hitTestMoveRecursive(t,e,s,r,n,a=!1){let o=!1;if(this._interactivePrune(t))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(we.pauseUpdate=!1),t.interactiveChildren&&t.children){const u=t.children;for(let c=u.length-1;c>=0;c--){const d=u[c],f=this.hitTestMoveRecursive(d,this._isInteractive(e)?e:d.eventMode,s,r,n,a||n(t,s));if(f){if(f.length>0&&!f[f.length-1].parent)continue;const p=t.isInteractive();(f.length>0||p)&&(p&&this._allInteractiveElements.push(t),f.push(t)),this._hitElements.length===0&&(this._hitElements=f),o=!0}}}const h=this._isInteractive(e),l=t.isInteractive();return l&&l&&this._allInteractiveElements.push(t),a||this._hitElements.length>0?null:o?this._hitElements:h&&!n(t,s)&&r(t,s)?l?[t]:[]:null}hitTestRecursive(t,e,s,r,n){if(this._interactivePrune(t)||n(t,s))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(we.pauseUpdate=!1),t.interactiveChildren&&t.children){const h=t.children;for(let l=h.length-1;l>=0;l--){const u=h[l],c=this.hitTestRecursive(u,this._isInteractive(e)?e:u.eventMode,s,r,n);if(c){if(c.length>0&&!c[c.length-1].parent)continue;const d=t.isInteractive();return(c.length>0||d)&&c.push(t),c}}}const a=this._isInteractive(e),o=t.isInteractive();return a&&r(t,s)?o?[t]:[]:null}_isInteractive(t){return t==="static"||t==="dynamic"}_interactivePrune(t){return!!(!t||t.isMask||!t.visible||!t.renderable||t.eventMode==="none"||t.eventMode==="passive"&&!t.interactiveChildren||t.isMask)}hitPruneFn(t,e){var s;if(t.hitArea&&(t.worldTransform.applyInverse(e,qn),!t.hitArea.contains(qn.x,qn.y)))return!0;if(t._mask){const r=t._mask.isMaskData?t._mask.maskObject:t._mask;if(r&&!((s=r.containsPoint)!=null&&s.call(r,e)))return!0}return!1}hitTestFn(t,e){return t.eventMode==="passive"?!1:t.hitArea?!0:t.containsPoint?t.containsPoint(e):!1}notifyTarget(t,e){var s,r;e=e!=null?e:t.type;const n=`on${e}`;(r=(s=t.currentTarget)[n])==null||r.call(s,t);const a=t.eventPhase===t.CAPTURING_PHASE||t.eventPhase===t.AT_TARGET?`${e}capture`:e;this.notifyListeners(t,a),t.eventPhase===t.AT_TARGET&&this.notifyListeners(t,e)}mapPointerDown(t){if(!(t instanceof kt)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.createPointerEvent(t);if(this.dispatchEvent(e,"pointerdown"),e.pointerType==="touch")this.dispatchEvent(e,"touchstart");else if(e.pointerType==="mouse"||e.pointerType==="pen"){const r=e.button===2;this.dispatchEvent(e,r?"rightdown":"mousedown")}const s=this.trackingData(t.pointerId);s.pressTargetsByButton[t.button]=e.composedPath(),this.freeEvent(e)}mapPointerMove(t){var e,s,r;if(!(t instanceof kt)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;const n=this.createPointerEvent(t);this._isPointerMoveEvent=!1;const a=n.pointerType==="mouse"||n.pointerType==="pen",o=this.trackingData(t.pointerId),h=this.findMountedTarget(o.overTargets);if(((e=o.overTargets)==null?void 0:e.length)>0&&h!==n.target){const c=t.type==="mousemove"?"mouseout":"pointerout",d=this.createPointerEvent(t,c,h);if(this.dispatchEvent(d,"pointerout"),a&&this.dispatchEvent(d,"mouseout"),!n.composedPath().includes(h)){const f=this.createPointerEvent(t,"pointerleave",h);for(f.eventPhase=f.AT_TARGET;f.target&&!n.composedPath().includes(f.target);)f.currentTarget=f.target,this.notifyTarget(f),a&&this.notifyTarget(f,"mouseleave"),f.target=f.target.parent;this.freeEvent(f)}this.freeEvent(d)}if(h!==n.target){const c=t.type==="mousemove"?"mouseover":"pointerover",d=this.clonePointerEvent(n,c);this.dispatchEvent(d,"pointerover"),a&&this.dispatchEvent(d,"mouseover");let f=h==null?void 0:h.parent;for(;f&&f!==this.rootTarget.parent&&f!==n.target;)f=f.parent;if(!f||f===this.rootTarget.parent){const p=this.clonePointerEvent(n,"pointerenter");for(p.eventPhase=p.AT_TARGET;p.target&&p.target!==h&&p.target!==this.rootTarget.parent;)p.currentTarget=p.target,this.notifyTarget(p),a&&this.notifyTarget(p,"mouseenter"),p.target=p.target.parent;this.freeEvent(p)}this.freeEvent(d)}const l=[],u=(s=this.enableGlobalMoveEvents)!=null?s:!0;this.moveOnAll?l.push("pointermove"):this.dispatchEvent(n,"pointermove"),u&&l.push("globalpointermove"),n.pointerType==="touch"&&(this.moveOnAll?l.splice(1,0,"touchmove"):this.dispatchEvent(n,"touchmove"),u&&l.push("globaltouchmove")),a&&(this.moveOnAll?l.splice(1,0,"mousemove"):this.dispatchEvent(n,"mousemove"),u&&l.push("globalmousemove"),this.cursor=(r=n.target)==null?void 0:r.cursor),l.length>0&&this.all(n,l),this._allInteractiveElements.length=0,this._hitElements.length=0,o.overTargets=n.composedPath(),this.freeEvent(n)}mapPointerOver(t){var e;if(!(t instanceof kt)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const s=this.trackingData(t.pointerId),r=this.createPointerEvent(t),n=r.pointerType==="mouse"||r.pointerType==="pen";this.dispatchEvent(r,"pointerover"),n&&this.dispatchEvent(r,"mouseover"),r.pointerType==="mouse"&&(this.cursor=(e=r.target)==null?void 0:e.cursor);const a=this.clonePointerEvent(r,"pointerenter");for(a.eventPhase=a.AT_TARGET;a.target&&a.target!==this.rootTarget.parent;)a.currentTarget=a.target,this.notifyTarget(a),n&&this.notifyTarget(a,"mouseenter"),a.target=a.target.parent;s.overTargets=r.composedPath(),this.freeEvent(r),this.freeEvent(a)}mapPointerOut(t){if(!(t instanceof kt)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId);if(e.overTargets){const s=t.pointerType==="mouse"||t.pointerType==="pen",r=this.findMountedTarget(e.overTargets),n=this.createPointerEvent(t,"pointerout",r);this.dispatchEvent(n),s&&this.dispatchEvent(n,"mouseout");const a=this.createPointerEvent(t,"pointerleave",r);for(a.eventPhase=a.AT_TARGET;a.target&&a.target!==this.rootTarget.parent;)a.currentTarget=a.target,this.notifyTarget(a),s&&this.notifyTarget(a,"mouseleave"),a.target=a.target.parent;e.overTargets=null,this.freeEvent(n),this.freeEvent(a)}this.cursor=null}mapPointerUp(t){if(!(t instanceof kt)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=performance.now(),s=this.createPointerEvent(t);if(this.dispatchEvent(s,"pointerup"),s.pointerType==="touch")this.dispatchEvent(s,"touchend");else if(s.pointerType==="mouse"||s.pointerType==="pen"){const o=s.button===2;this.dispatchEvent(s,o?"rightup":"mouseup")}const r=this.trackingData(t.pointerId),n=this.findMountedTarget(r.pressTargetsByButton[t.button]);let a=n;if(n&&!s.composedPath().includes(n)){let o=n;for(;o&&!s.composedPath().includes(o);){if(s.currentTarget=o,this.notifyTarget(s,"pointerupoutside"),s.pointerType==="touch")this.notifyTarget(s,"touchendoutside");else if(s.pointerType==="mouse"||s.pointerType==="pen"){const h=s.button===2;this.notifyTarget(s,h?"rightupoutside":"mouseupoutside")}o=o.parent}delete r.pressTargetsByButton[t.button],a=o}if(a){const o=this.clonePointerEvent(s,"click");o.target=a,o.path=null,r.clicksByButton[t.button]||(r.clicksByButton[t.button]={clickCount:0,target:o.target,timeStamp:e});const h=r.clicksByButton[t.button];if(h.target===o.target&&e-h.timeStamp<200?++h.clickCount:h.clickCount=1,h.target=o.target,h.timeStamp=e,o.detail=h.clickCount,o.pointerType==="mouse"){const l=o.button===2;this.dispatchEvent(o,l?"rightclick":"click")}else o.pointerType==="touch"&&this.dispatchEvent(o,"tap");this.dispatchEvent(o,"pointertap"),this.freeEvent(o)}this.freeEvent(s)}mapPointerUpOutside(t){if(!(t instanceof kt)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId),s=this.findMountedTarget(e.pressTargetsByButton[t.button]),r=this.createPointerEvent(t);if(s){let n=s;for(;n;)r.currentTarget=n,this.notifyTarget(r,"pointerupoutside"),r.pointerType==="touch"?this.notifyTarget(r,"touchendoutside"):(r.pointerType==="mouse"||r.pointerType==="pen")&&this.notifyTarget(r,r.button===2?"rightupoutside":"mouseupoutside"),n=n.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(r)}mapWheel(t){if(!(t instanceof He)){console.warn("EventBoundary cannot map a non-wheel event as a wheel event");return}const e=this.createWheelEvent(t);this.dispatchEvent(e),this.freeEvent(e)}findMountedTarget(t){if(!t)return null;let e=t[0];for(let s=1;st in i?Vf(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,zf=(i,t)=>{for(var e in t||(t={}))jf.call(t,e)&&Wh(i,e,t[e]);if(zh)for(var e of zh(t))Xf.call(t,e)&&Wh(i,e,t[e]);return i};const Wf=1,Yf={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},Kn=class Ra{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new Xh(null),we.init(this),this.autoPreventDefault=!0,this.eventsAdded=!1,this.rootPointerEvent=new kt(null),this.rootWheelEvent=new He(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy(zf({},Ra.defaultEventFeatures),{set:(e,s,r)=>(s==="globalMove"&&(this.rootBoundary.enableGlobalMoveEvents=r),e[s]=r,!0)}),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.onPointerOverOut=this.onPointerOverOut.bind(this),this.onWheel=this.onWheel.bind(this)}static get defaultEventMode(){return this._defaultEventMode}init(t){var e,s;const{view:r,resolution:n}=this.renderer;this.setTargetElement(r),this.resolution=n,Ra._defaultEventMode=(e=t.eventMode)!=null?e:"auto",Object.assign(this.features,(s=t.eventFeatures)!=null?s:{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(t){this.resolution=t}destroy(){this.setTargetElement(null),this.renderer=null}setCursor(t){t=t||"default";let e=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(e=!1),this.currentCursor===t)return;this.currentCursor=t;const s=this.cursorStyles[t];if(s)switch(typeof s){case"string":e&&(this.domElement.style.cursor=s);break;case"function":s(t);break;case"object":e&&Object.assign(this.domElement.style,s);break}else e&&typeof t=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,t)&&(this.domElement.style.cursor=t)}get pointer(){return this.rootPointerEvent}onPointerDown(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this.normalizeToPointerData(t);this.autoPreventDefault&&e[0].isNormalized&&(t.cancelable||!("cancelable"in t))&&t.preventDefault();for(let s=0,r=e.length;s0&&(e=t.composedPath()[0]);const s=e!==this.domElement?"outside":"",r=this.normalizeToPointerData(t);for(let n=0,a=r.length;n{this._isMobileAccessibility=!0,this.activate(),this.destroyTouchHook()}),document.body.appendChild(t),this._hookDiv=t}destroyTouchHook(){this._hookDiv&&(document.body.removeChild(this._hookDiv),this._hookDiv=null)}activate(){var t;this._isActive||(this._isActive=!0,globalThis.document.addEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown,!1),this.renderer.on("postrender",this.update,this),(t=this.renderer.view.parentNode)==null||t.appendChild(this.div))}deactivate(){var t;!this._isActive||this._isMobileAccessibility||(this._isActive=!1,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.addEventListener("keydown",this._onKeyDown,!1),this.renderer.off("postrender",this.update),(t=this.div.parentNode)==null||t.removeChild(this.div))}updateAccessibleObjects(t){if(!t.visible||!t.accessibleChildren)return;t.accessible&&t.isInteractive()&&(t._accessibleActive||this.addChild(t),t.renderId=this.renderId);const e=t.children;if(e)for(let s=0;s title : ${t.title}
tabIndex: ${t.tabIndex}`}capHitArea(t){t.x<0&&(t.width+=t.x,t.x=0),t.y<0&&(t.height+=t.y,t.y=0);const{width:e,height:s}=this.renderer;t.x+t.width>e&&(t.width=e-t.x),t.y+t.height>s&&(t.height=s-t.y)}addChild(t){let e=this.pool.pop();e||(e=document.createElement("button"),e.style.width=`${er}px`,e.style.height=`${er}px`,e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=Zh.toString(),e.style.borderStyle="none",navigator.userAgent.toLowerCase().includes("chrome")?e.setAttribute("aria-live","off"):e.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?e.setAttribute("aria-relevant","additions"):e.setAttribute("aria-relevant","text"),e.addEventListener("click",this._onClick.bind(this)),e.addEventListener("focus",this._onFocus.bind(this)),e.addEventListener("focusout",this._onFocusOut.bind(this))),e.style.pointerEvents=t.accessiblePointerEvents,e.type=t.accessibleType,t.accessibleTitle&&t.accessibleTitle!==null?e.title=t.accessibleTitle:(!t.accessibleHint||t.accessibleHint===null)&&(e.title=`displayObject ${t.tabIndex}`),t.accessibleHint&&t.accessibleHint!==null&&e.setAttribute("aria-label",t.accessibleHint),this.debug&&this.updateDebugHTML(e),t._accessibleActive=!0,t._accessibleDiv=e,e.displayObject=t,this.children.push(t),this.div.appendChild(t._accessibleDiv),t._accessibleDiv.tabIndex=t.tabIndex}_dispatchEvent(t,e){const{displayObject:s}=t.target,r=this.renderer.events.rootBoundary,n=Object.assign(new Je(r),{target:s});r.rootTarget=this.renderer.lastObjectRendered,e.forEach(a=>r.dispatchEvent(n,a))}_onClick(t){this._dispatchEvent(t,["click","pointertap","tap"])}_onFocus(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","assertive"),this._dispatchEvent(t,["mouseover"])}_onFocusOut(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","polite"),this._dispatchEvent(t,["mouseout"])}_onKeyDown(t){t.keyCode===qf&&this.activate()}_onMouseMove(t){t.movementX===0&&t.movementY===0||this.deactivate()}destroy(){this.destroyTouchHook(),this.div=null,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown),this.pool=null,this.children=null,this.renderer=null}}Zn.extension={name:"accessibility",type:[D.RendererPlugin,D.CanvasRendererPlugin]},U.add(Zn);const Jh=class Ia{constructor(t){this.stage=new St,t=Object.assign({forceCanvas:!1},t),this.renderer=Sh(t),Ia._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render(this.stage)}get view(){var t;return(t=this.renderer)==null?void 0:t.view}get screen(){var t;return(t=this.renderer)==null?void 0:t.screen}destroy(t,e){const s=Ia._plugins.slice(0);s.reverse(),s.forEach(r=>{r.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};Jh._plugins=[];let tl=Jh;U.handleByList(D.Application,tl._plugins);class Qn{static init(t){Object.defineProperty(this,"resizeTo",{set(e){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=e,e&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this.cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this.cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this.cancelResize();let e,s;if(this._resizeTo===globalThis.window)e=globalThis.innerWidth,s=globalThis.innerHeight;else{const{clientWidth:r,clientHeight:n}=this._resizeTo;e=r,s=n}this.renderer.resize(e,s),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=t.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this.cancelResize(),this.cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}Qn.extension=D.Application,U.add(Qn);const el={loader:D.LoadParser,resolver:D.ResolveParser,cache:D.CacheParser,detection:D.DetectionParser};U.handle(D.Asset,i=>{const t=i.ref;Object.entries(el).filter(([e])=>!!t[e]).forEach(([e,s])=>{var r;return U.add(Object.assign(t[e],{extension:(r=t[e].extension)!=null?r:s}))})},i=>{const t=i.ref;Object.keys(el).filter(e=>!!t[e]).forEach(e=>U.remove(t[e]))});class ep{constructor(t,e=!1){this._loader=t,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=e}add(t){t.forEach(e=>{this._assetList.push(e)}),this.verbose&&console.log("[BackgroundLoader] assets: ",this._assetList),this._isActive&&!this._isLoading&&this._next()}async _next(){if(this._assetList.length&&this._isActive){this._isLoading=!0;const t=[],e=Math.min(this._assetList.length,this._maxConcurrent);for(let s=0;s(Array.isArray(i)||(i=[i]),t?i.map(e=>typeof e=="string"?t(e):e):i),sr=(i,t)=>{const e=t.split("?")[1];return e&&(i+=`?${e}`),i};function sl(i,t,e,s,r){const n=t[e];for(let a=0;a{const a=n.substring(1,n.length-1).split(",");r.push(a)}),sl(i,r,0,e,s)}else s.push(i);return s}const $s=i=>!Array.isArray(i);let sp=class{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(t){return this._cache.has(t)}get(t){return this._cache.get(t)}set(t,e){const s=Gt(t);let r;for(let o=0;o{r[o]=e}));const n=Object.keys(r),a={cacheKeys:n,keys:s};if(s.forEach(o=>{this._cacheMap.set(o,a)}),n.forEach(o=>{this._cache.has(o)&&this._cache.get(o),this._cache.set(o,r[o])}),e instanceof L){const o=e;s.forEach(h=>{o.baseTexture!==L.EMPTY.baseTexture&&X.addToCache(o.baseTexture,h),L.addToCache(o,h)})}}remove(t){if(!this._cacheMap.has(t))return;const e=this._cacheMap.get(t);e.cacheKeys.forEach(s=>{this._cache.delete(s)}),e.keys.forEach(s=>{this._cacheMap.delete(s)})}get parsers(){return this._parsers}};const Se=new sp;var ip=Object.defineProperty,rp=Object.defineProperties,np=Object.getOwnPropertyDescriptors,rl=Object.getOwnPropertySymbols,ap=Object.prototype.hasOwnProperty,op=Object.prototype.propertyIsEnumerable,nl=(i,t,e)=>t in i?ip(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,hp=(i,t)=>{for(var e in t||(t={}))ap.call(t,e)&&nl(i,e,t[e]);if(rl)for(var e of rl(t))op.call(t,e)&&nl(i,e,t[e]);return i},lp=(i,t)=>rp(i,np(t));class up{constructor(){this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,e,s)=>(this._parsersValidated=!1,t[e]=s,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,e){const s={promise:null,parser:null};return s.promise=(async()=>{var r,n;let a=null,o=null;if(e.loadParser&&(o=this._parserHash[e.loadParser]),!o){for(let h=0;h({alias:[l],src:l})),o=a.length,h=a.map(async l=>{const u=bt.toAbsolute(l.src);if(!r[l.src])try{this.promiseCache[u]||(this.promiseCache[u]=this._getLoadPromiseAndParser(u,l)),r[l.src]=await this.promiseCache[u].promise,e&&e(++s/o)}catch(c){throw delete this.promiseCache[u],delete r[l.src],new Error(`[Loader.load] Failed to load ${u}. +${c}`)}});return await Promise.all(h),n?r[a[0].src]:r}async unload(t){const e=Gt(t,s=>({alias:[s],src:s})).map(async s=>{var r,n;const a=bt.toAbsolute(s.src),o=this.promiseCache[a];if(o){const h=await o.promise;delete this.promiseCache[a],(n=(r=o.parser)==null?void 0:r.unload)==null||n.call(r,h,s,this)}});await Promise.all(e)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name).reduce((t,e)=>(t[e.name],lp(hp({},t),{[e.name]:e})),{})}}var $t=(i=>(i[i.Low=0]="Low",i[i.Normal=1]="Normal",i[i.High=2]="High",i))($t||{});const cp=".json",dp="application/json",al={extension:{type:D.LoadParser,priority:$t.Low},name:"loadJson",test(i){return Ve(i,dp)||_e(i,cp)},async load(i){return await(await N.ADAPTER.fetch(i)).json()}};U.add(al);const fp=".txt",pp="text/plain",ol={name:"loadTxt",extension:{type:D.LoadParser,priority:$t.Low},test(i){return Ve(i,pp)||_e(i,fp)},async load(i){return await(await N.ADAPTER.fetch(i)).text()}};U.add(ol);var mp=Object.defineProperty,gp=Object.defineProperties,_p=Object.getOwnPropertyDescriptors,hl=Object.getOwnPropertySymbols,vp=Object.prototype.hasOwnProperty,yp=Object.prototype.propertyIsEnumerable,ll=(i,t,e)=>t in i?mp(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,xp=(i,t)=>{for(var e in t||(t={}))vp.call(t,e)&&ll(i,e,t[e]);if(hl)for(var e of hl(t))yp.call(t,e)&&ll(i,e,t[e]);return i},bp=(i,t)=>gp(i,_p(t));const Tp=["normal","bold","100","200","300","400","500","600","700","800","900"],Ep=[".ttf",".otf",".woff",".woff2"],Ap=["font/ttf","font/otf","font/woff","font/woff2"],wp=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function ul(i){const t=bt.extname(i),e=bt.basename(i,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1));let s=e.length>0;for(const n of e)if(!n.match(wp)){s=!1;break}let r=e.join(" ");return s||(r=`"${r.replace(/[\\"]/g,"\\$&")}"`),r}const cl={extension:{type:D.LoadParser,priority:$t.Low},name:"loadWebFont",test(i){return Ve(i,Ap)||_e(i,Ep)},async load(i,t){var e,s,r,n,a,o;const h=N.ADAPTER.getFontFaceSet();if(h){const l=[],u=(s=(e=t.data)==null?void 0:e.family)!=null?s:ul(i),c=(a=(n=(r=t.data)==null?void 0:r.weights)==null?void 0:n.filter(f=>Tp.includes(f)))!=null?a:["normal"],d=(o=t.data)!=null?o:{};for(let f=0;fN.ADAPTER.getFontFaceSet().delete(t))}};U.add(cl);let dl=0,Jn;const Sp="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=",Cp={id:"checkImageBitmap",code:` + async function checkImageBitmap() + { + try + { + if (typeof createImageBitmap !== 'function') return false; + + const response = await fetch('${Sp}'); + const imageBlob = await response.blob(); + const imageBitmap = await createImageBitmap(imageBlob); + + return imageBitmap.width === 1 && imageBitmap.height === 1; + } + catch (e) + { + return false; + } + } + checkImageBitmap().then((result) => { self.postMessage(result); }); + `},Rp={id:"loadImageBitmap",code:` + async function loadImageBitmap(url) + { + const response = await fetch(url); + + if (!response.ok) + { + throw new Error(\`[WorkerManager.loadImageBitmap] Failed to fetch \${url}: \` + + \`\${response.status} \${response.statusText}\`); + } + + const imageBlob = await response.blob(); + const imageBitmap = await createImageBitmap(imageBlob); + + return imageBitmap; + } + self.onmessage = async (event) => + { + try + { + const imageBitmap = await loadImageBitmap(event.data.data[0]); + + self.postMessage({ + data: imageBitmap, + uuid: event.data.uuid, + id: event.data.id, + }, [imageBitmap]); + } + catch(e) + { + self.postMessage({ + error: e, + uuid: event.data.uuid, + id: event.data.id, + }); + } + };`};let ta,Ip=class{constructor(){this._initialized=!1,this._createdWorkers=0,this.workerPool=[],this.queue=[],this.resolveHash={}}isImageBitmapSupported(){return this._isImageBitmapSupported!==void 0?this._isImageBitmapSupported:(this._isImageBitmapSupported=new Promise(t=>{const e=URL.createObjectURL(new Blob([Cp.code],{type:"application/javascript"})),s=new Worker(e);s.addEventListener("message",r=>{s.terminate(),URL.revokeObjectURL(e),t(r.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t){return this._run("loadImageBitmap",[t])}async _initWorkers(){this._initialized||(this._initialized=!0)}getWorker(){Jn===void 0&&(Jn=navigator.hardwareConcurrency||4);let t=this.workerPool.pop();return!t&&this._createdWorkers{this.complete(e.data),this.returnWorker(e.target),this.next()})),t}returnWorker(t){this.workerPool.push(t)}complete(t){t.error!==void 0?this.resolveHash[t.uuid].reject(t.error):this.resolveHash[t.uuid].resolve(t.data),this.resolveHash[t.uuid]=null}async _run(t,e){await this._initWorkers();const s=new Promise((r,n)=>{this.queue.push({id:t,arguments:e,resolve:r,reject:n})});return this.next(),s}next(){if(!this.queue.length)return;const t=this.getWorker();if(!t)return;const e=this.queue.pop(),s=e.id;this.resolveHash[dl]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:dl++,id:s})}};const fl=new Ip;function ts(i,t,e){i.resource.internal=!0;const s=new L(i),r=()=>{delete t.promiseCache[e],Se.has(e)&&Se.remove(e)};return s.baseTexture.once("destroyed",()=>{e in t.promiseCache&&(console.warn("[Assets] A BaseTexture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the BaseTexture."),r())}),s.once("destroyed",()=>{i.destroyed||(console.warn("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."),r())}),s}var Pp=Object.defineProperty,pl=Object.getOwnPropertySymbols,Mp=Object.prototype.hasOwnProperty,Dp=Object.prototype.propertyIsEnumerable,ml=(i,t,e)=>t in i?Pp(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,gl=(i,t)=>{for(var e in t||(t={}))Mp.call(t,e)&&ml(i,e,t[e]);if(pl)for(var e of pl(t))Dp.call(t,e)&&ml(i,e,t[e]);return i};const Op=[".jpeg",".jpg",".png",".webp",".avif"],Bp=["image/jpeg","image/png","image/webp","image/avif"];async function _l(i){const t=await N.ADAPTER.fetch(i);if(!t.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${i}: ${t.status} ${t.statusText}`);const e=await t.blob();return await createImageBitmap(e)}const Hs={name:"loadTextures",extension:{type:D.LoadParser,priority:$t.High},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(i){return Ve(i,Bp)||_e(i,Op)},async load(i,t,e){var s,r;const n=globalThis.createImageBitmap&&this.config.preferCreateImageBitmap;let a;n?this.config.preferWorkers&&await fl.isImageBitmapSupported()?a=await fl.loadImageBitmap(i):a=await _l(i):a=await new Promise((l,u)=>{const c=new Image;c.crossOrigin=this.config.crossOrigin,c.src=i,c.complete?l(c):(c.onload=()=>l(c),c.onerror=d=>u(d))});const o=gl({},t.data);(s=o.resolution)!=null||(o.resolution=te(i)),n&&((r=o.resourceOptions)==null?void 0:r.ownsImageBitmap)===void 0&&(o.resourceOptions=gl({},o.resourceOptions),o.resourceOptions.ownsImageBitmap=!0);const h=new X(a,o);return h.resource.src=i,ts(h,e,i)},unload(i){i.destroy(!0)}};U.add(Hs);var Fp=Object.defineProperty,vl=Object.getOwnPropertySymbols,Np=Object.prototype.hasOwnProperty,Lp=Object.prototype.propertyIsEnumerable,yl=(i,t,e)=>t in i?Fp(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,Up=(i,t)=>{for(var e in t||(t={}))Np.call(t,e)&&yl(i,e,t[e]);if(vl)for(var e of vl(t))Lp.call(t,e)&&yl(i,e,t[e]);return i};const kp=".svg",Gp="image/svg+xml",xl={extension:{type:D.LoadParser,priority:$t.High},name:"loadSVG",test(i){return Ve(i,Gp)||_e(i,kp)},async testParse(i){return Xi.test(i)},async parse(i,t,e){var s;const r=new Xi(i,(s=t==null?void 0:t.data)==null?void 0:s.resourceOptions);await r.load();const n=new X(r,Up({resolution:te(i)},t==null?void 0:t.data));return n.resource.src=t.src,ts(n,e,t.src)},async load(i,t){return(await N.ADAPTER.fetch(i)).text()},unload:Hs.unload};U.add(xl);var $p=Object.defineProperty,bl=Object.getOwnPropertySymbols,Hp=Object.prototype.hasOwnProperty,Vp=Object.prototype.propertyIsEnumerable,Tl=(i,t,e)=>t in i?$p(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,El=(i,t)=>{for(var e in t||(t={}))Hp.call(t,e)&&Tl(i,e,t[e]);if(bl)for(var e of bl(t))Vp.call(t,e)&&Tl(i,e,t[e]);return i};const jp=[".mp4",".m4v",".webm",".ogv"],Xp=["video/mp4","video/webm","video/ogg"],Al={name:"loadVideo",extension:{type:D.LoadParser,priority:$t.High},config:{defaultAutoPlay:!0},test(i){return Ve(i,Xp)||_e(i,jp)},async load(i,t,e){var s;let r;const n=await(await N.ADAPTER.fetch(i)).blob(),a=URL.createObjectURL(n);try{const o=El({autoPlay:this.config.defaultAutoPlay},(s=t==null?void 0:t.data)==null?void 0:s.resourceOptions),h=new kn(a,o);await h.load();const l=new X(h,El({alphaMode:await no(),resolution:te(i)},t==null?void 0:t.data));l.resource.src=i,r=ts(l,e,i),r.baseTexture.once("destroyed",()=>{URL.revokeObjectURL(a)})}catch(o){throw URL.revokeObjectURL(a),o}return r},unload(i){i.destroy(!0)}};U.add(Al);var zp=Object.defineProperty,Wp=Object.defineProperties,Yp=Object.getOwnPropertyDescriptors,wl=Object.getOwnPropertySymbols,qp=Object.prototype.hasOwnProperty,Kp=Object.prototype.propertyIsEnumerable,Sl=(i,t,e)=>t in i?zp(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,es=(i,t)=>{for(var e in t||(t={}))qp.call(t,e)&&Sl(i,e,t[e]);if(wl)for(var e of wl(t))Kp.call(t,e)&&Sl(i,e,t[e]);return i},Cl=(i,t)=>Wp(i,Yp(t));class Zp{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(t,e)=>`${t}${this._bundleIdConnector}${e}`,extractAssetIdFromBundle:(t,e)=>e.replace(`${t}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(t){var e,s,r;if(this._bundleIdConnector=(e=t.connector)!=null?e:this._bundleIdConnector,this._createBundleAssetId=(s=t.createBundleAssetId)!=null?s:this._createBundleAssetId,this._extractAssetIdFromBundle=(r=t.extractAssetIdFromBundle)!=null?r:this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...t){t.forEach(e=>{this._preferredOrder.push(e),e.priority||(e.priority=Object.keys(e.params))}),this._resolverHash={}}set basePath(t){this._basePath=t}get basePath(){return this._basePath}set rootPath(t){this._rootPath=t}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(t){if(typeof t=="string")this._defaultSearchParams=t;else{const e=t;this._defaultSearchParams=Object.keys(e).map(s=>`${encodeURIComponent(s)}=${encodeURIComponent(e[s])}`).join("&")}}addManifest(t){this._manifest,this._manifest=t,t.bundles.forEach(e=>{this.addBundle(e.name,e.assets)})}addBundle(t,e){const s=[];Array.isArray(e)?e.forEach(r=>{var n,a;const o=(n=r.src)!=null?n:r.srcs,h=(a=r.alias)!=null?a:r.name;let l;if(typeof h=="string"){const u=this._createBundleAssetId(t,h);s.push(u),l=[h,u]}else{const u=h.map(c=>this._createBundleAssetId(t,c));s.push(...u),l=[...h,...u]}this.add(Cl(es({},r),{alias:l,src:o}))}):Object.keys(e).forEach(r=>{var n;const a=[r,this._createBundleAssetId(t,r)];if(typeof e[r]=="string")this.add({alias:a,src:e[r]});else if(Array.isArray(e[r]))this.add({alias:a,src:e[r]});else{const o=e[r],h=(n=o.src)!=null?n:o.srcs;this.add(Cl(es({},o),{alias:a,src:Array.isArray(h)?h:[h]}))}s.push(...a)}),this._bundles[t]=s}add(t,e,s,r,n){const a=[];typeof t=="string"||Array.isArray(t)&&typeof t[0]=="string"?a.push({alias:t,src:e,data:s,format:r,loadParser:n}):Array.isArray(t)?a.push(...t):a.push(t);let o;Gt(a).forEach(h=>{const{alias:l,name:u,src:c,srcs:d}=h;let{data:f,format:p,loadParser:m}=h;const g=Gt(c||d).map(v=>typeof v=="string"?il(v):Array.isArray(v)?v:[v]),_=Gt(l||u),x=[];g.forEach(v=>{v.forEach(b=>{var T,R,w;let A={};if(typeof b!="object"){A.src=b;for(let S=0;S{this._assetMap[v]=x})})}resolveBundle(t){const e=$s(t);t=Gt(t);const s={};return t.forEach(r=>{const n=this._bundles[r];if(n){const a=this.resolve(n),o={};for(const h in a){const l=a[h];o[this._extractAssetIdFromBundle(r,h)]=l}s[r]=o}}),e?s[t[0]]:s}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const s={};for(const r in e)s[r]=e[r].src;return s}return e.src}resolve(t){const e=$s(t);t=Gt(t);const s={};return t.forEach(r=>{var n;if(!this._resolverHash[r])if(this._assetMap[r]){let a=this._assetMap[r];const o=a[0],h=this._getPreferredOrder(a);h==null||h.priority.forEach(l=>{h.params[l].forEach(u=>{const c=a.filter(d=>d[l]?d[l]===u:!1);c.length&&(a=c)})}),this._resolverHash[r]=(n=a[0])!=null?n:o}else this._resolverHash[r]=this.buildResolvedAsset({alias:[r],src:r},{});s[r]=this._resolverHash[r]}),e?s[t[0]]:s}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;en.params.format.includes(s.format));if(r)return r}return this._preferredOrder[0]}_appendDefaultSearchParams(t){if(!this._defaultSearchParams)return t;const e=/\?/.test(t)?"&":"?";return`${t}${e}${this._defaultSearchParams}`}buildResolvedAsset(t,e){var s;const{aliases:r,data:n,loadParser:a,format:o}=e;return(this._basePath||this._rootPath)&&(t.src=bt.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=(s=r!=null?r:t.alias)!=null?s:[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data=es(es({},n||{}),t.data),t.loadParser=a!=null?a:t.loadParser,t.format=o!=null?o:t.src.split(".").pop(),t.srcs=t.src,t.name=t.alias,t}}class Rl{constructor(){this._detections=[],this._initialized=!1,this.resolver=new Zp,this.loader=new up,this.cache=Se,this._backgroundLoader=new ep(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){var e,s,r;if(this._initialized)return;if(this._initialized=!0,t.defaultSearchParams&&this.resolver.setDefaultSearchParams(t.defaultSearchParams),t.basePath&&(this.resolver.basePath=t.basePath),t.bundleIdentifier&&this.resolver.setBundleIdentifier(t.bundleIdentifier),t.manifest){let h=t.manifest;typeof h=="string"&&(h=await this.load(h)),this.resolver.addManifest(h)}const n=(s=(e=t.texturePreference)==null?void 0:e.resolution)!=null?s:1,a=typeof n=="number"?[n]:n,o=await this._detectFormats({preferredFormats:(r=t.texturePreference)==null?void 0:r.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:o,resolution:a}}),t.preferences&&this.setPreferences(t.preferences)}add(t,e,s,r,n){this.resolver.add(t,e,s,r,n)}async load(t,e){this._initialized||await this.init();const s=$s(t),r=Gt(t).map(o=>{if(typeof o!="string"){this.add(o);const h=o.src||o.srcs,l=o.alias||o.name;return l&&Array.isArray(l)?l[0]:h&&Array.isArray(h)?h[0]:l||h}return this.resolver.hasKey(o)||this.add({alias:o,src:o}),o}),n=this.resolver.resolve(r),a=await this._mapLoadToResolve(n,e);return s?a[r[0]]:a}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let s=!1;typeof t=="string"&&(s=!0,t=[t]);const r=this.resolver.resolveBundle(t),n={},a=Object.keys(r);let o=0,h=0;const l=()=>{e==null||e(++o/h)},u=a.map(c=>{const d=r[c];return h+=Object.keys(d).length,this._mapLoadToResolve(d,l).then(f=>{n[c]=f})});return await Promise.all(u),s?n[t[0]]:n}async backgroundLoad(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolve(t);this._backgroundLoader.add(Object.values(e))}async backgroundLoadBundle(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolveBundle(t);Object.values(e).forEach(s=>{this._backgroundLoader.add(Object.values(s))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if(typeof t=="string")return Se.get(t);const e={};for(let s=0;s{const l=n[o.src],u=[o.src];o.alias&&u.push(...o.alias),a[r[h]]=l,Se.set(u,l)}),a}async unload(t){this._initialized||await this.init();const e=Gt(t).map(r=>typeof r!="string"?r.src:r),s=this.resolver.resolve(e);await this._unloadFromResolved(s)}async unloadBundle(t){this._initialized||await this.init(),t=Gt(t);const e=this.resolver.resolveBundle(t),s=Object.keys(e).map(r=>this._unloadFromResolved(e[r]));await Promise.all(s)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(s=>{Se.remove(s.src)}),await this.loader.unload(e)}async _detectFormats(t){let e=[];t.preferredFormats&&(e=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(const s of t.detections)t.skipDetections||await s.test()?e=await s.add(e):t.skipDetections||(e=await s.remove(e));return e=e.filter((s,r)=>e.indexOf(s)===r),e}get detections(){return this._detections}get preferWorkers(){return Hs.config.preferWorkers}set preferWorkers(t){this.setPreferences({preferWorkers:t})}setPreferences(t){this.loader.parsers.forEach(e=>{e.config&&Object.keys(e.config).filter(s=>s in t).forEach(s=>{e.config[s]=t[s]})})}}const Vs=new Rl;U.handleByList(D.LoadParser,Vs.loader.parsers).handleByList(D.ResolveParser,Vs.resolver.parsers).handleByList(D.CacheParser,Vs.cache.parsers).handleByList(D.DetectionParser,Vs.detections);const Il={extension:D.CacheParser,test:i=>Array.isArray(i)&&i.every(t=>t instanceof L),getCacheableAssets:(i,t)=>{const e={};return i.forEach(s=>{t.forEach((r,n)=>{e[s+(n===0?"":n+1)]=r})}),e}};U.add(Il);const Pl={extension:{type:D.DetectionParser,priority:1},test:async()=>{const i="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A=";return new Promise(t=>{const e=new Image;e.onload=()=>{t(!0)},e.onerror=()=>{t(!1)},e.src=i})},add:async i=>[...i,"avif"],remove:async i=>i.filter(t=>t!=="avif")};U.add(Pl);const Ml={extension:{type:D.DetectionParser,priority:0},test:async()=>{const i="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA=";return new Promise(t=>{const e=new Image;e.onload=()=>{t(!0)},e.onerror=()=>{t(!1)},e.src=i})},add:async i=>[...i,"webp"],remove:async i=>i.filter(t=>t!=="webp")};U.add(Ml);const Dl=["png","jpg","jpeg"],Ol={extension:{type:D.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async i=>[...i,...Dl],remove:async i=>i.filter(t=>!Dl.includes(t))};U.add(Ol);const Qp="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function ea(i){return Qp?!1:document.createElement("video").canPlayType(i)!==""}const Bl={extension:{type:D.DetectionParser,priority:0},test:async()=>ea("video/webm"),add:async i=>[...i,"webm"],remove:async i=>i.filter(t=>t!=="webm")};U.add(Bl);const Fl={extension:{type:D.DetectionParser,priority:0},test:async()=>ea("video/mp4"),add:async i=>[...i,"mp4","m4v"],remove:async i=>i.filter(t=>t!=="mp4"&&t!=="m4v")};U.add(Fl);const Nl={extension:{type:D.DetectionParser,priority:0},test:async()=>ea("video/ogg"),add:async i=>[...i,"ogv"],remove:async i=>i.filter(t=>t!=="ogv")};U.add(Nl);const Ll={extension:D.ResolveParser,test:Hs.test,parse:i=>{var t,e;return{resolution:parseFloat((e=(t=N.RETINA_PREFIX.exec(i))==null?void 0:t[1])!=null?e:"1"),format:i.split(".").pop(),src:i}}};U.add(Ll);var Ct=(i=>(i[i.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",i[i.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",i[i.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",i[i.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",i[i.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",i[i.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",i[i.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",i[i.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",i[i.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",i[i.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",i[i.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",i[i.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",i[i.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",i[i.COMPRESSED_RGBA8_ETC2_EAC=37496]="COMPRESSED_RGBA8_ETC2_EAC",i[i.COMPRESSED_SRGB8_ETC2=37493]="COMPRESSED_SRGB8_ETC2",i[i.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37497]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",i[i.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",i[i.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",i[i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",i[i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",i[i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",i[i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",i[i.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",i[i.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",i[i.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",i[i.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",i[i.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",i))(Ct||{});const js={33776:.5,33777:.5,33778:1,33779:1,35916:.5,35917:.5,35918:1,35919:1,37488:.5,37489:.5,37490:1,37491:1,37492:.5,37496:1,37493:.5,37497:1,37494:.5,37495:.5,35840:.5,35842:.5,35841:.25,35843:.25,36196:.5,35986:.5,35986:1,34798:1,37808:1};let ve,ss;function Ul(){ss={s3tc:ve.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:ve.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:ve.getExtension("WEBGL_compressed_texture_etc"),etc1:ve.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:ve.getExtension("WEBGL_compressed_texture_pvrtc")||ve.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:ve.getExtension("WEBGL_compressed_texture_atc"),astc:ve.getExtension("WEBGL_compressed_texture_astc")}}const kl={extension:{type:D.DetectionParser,priority:2},test:async()=>{const i=N.ADAPTER.createCanvas().getContext("webgl");return i?(ve=i,!0):!1},add:async i=>{ss||Ul();const t=[];for(const e in ss)ss[e]&&t.push(e);return[...t,...i]},remove:async i=>(ss||Ul(),i.filter(t=>!(t in ss)))};U.add(kl);class Gl extends xs{constructor(t,e={width:1,height:1,autoLoad:!0}){let s,r;typeof t=="string"?(s=t,r=new Uint8Array):(s=null,r=t),super(r,e),this.origin=s,this.buffer=r?new Ti(r):null,this._load=null,this.loaded=!1,this.origin!==null&&e.autoLoad!==!1&&this.load(),this.origin===null&&this.buffer&&(this._load=Promise.resolve(this),this.loaded=!0,this.onBlobLoaded(this.buffer.rawBinaryData))}onBlobLoaded(t){}load(){return this._load?this._load:(this._load=fetch(this.origin).then(t=>t.blob()).then(t=>t.arrayBuffer()).then(t=>(this.data=new Uint32Array(t),this.buffer=new Ti(t),this.loaded=!0,this.onBlobLoaded(t),this.update(),this)),this._load)}}class Ce extends Gl{constructor(t,e){super(t,e),this.format=e.format,this.levels=e.levels||1,this._width=e.width,this._height=e.height,this._extension=Ce._formatToExtension(this.format),(e.levelBuffers||this.buffer)&&(this._levelBuffers=e.levelBuffers||Ce._createLevelBuffers(t instanceof Uint8Array?t:this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height))}upload(t,e,s){const r=t.gl;if(!t.context.extensions[this._extension])throw new Error(`${this._extension} textures are not supported on the current machine`);if(!this._levelBuffers)return!1;r.pixelStorei(r.UNPACK_ALIGNMENT,4);for(let n=0,a=this.levels;n=33776&&t<=33779)return"s3tc";if(t>=37488&&t<=37497)return"etc";if(t>=35840&&t<=35843)return"pvrtc";if(t>=36196)return"etc1";if(t>=35986&&t<=34798)return"atc";throw new Error("Invalid (compressed) texture format given!")}static _createLevelBuffers(t,e,s,r,n,a,o){const h=new Array(s);let l=t.byteOffset,u=a,c=o,d=u+r-1&~(r-1),f=c+n-1&~(n-1),p=d*f*js[e];for(let m=0;m1?u:d,levelHeight:s>1?c:f,levelBuffer:new Uint8Array(t.buffer,l,p)},l+=p,u=u>>1||1,c=c>>1||1,d=u+r-1&~(r-1),f=c+n-1&~(n-1),p=d*f*js[e];return h}}const sa=4,ir=124,Jp=32,$l=20,tm=542327876,rr={SIZE:1,FLAGS:2,HEIGHT:3,WIDTH:4,MIPMAP_COUNT:7,PIXEL_FORMAT:19},em={SIZE:0,FLAGS:1,FOURCC:2,RGB_BITCOUNT:3,R_BIT_MASK:4,G_BIT_MASK:5,B_BIT_MASK:6,A_BIT_MASK:7},nr={DXGI_FORMAT:0,RESOURCE_DIMENSION:1,MISC_FLAG:2,ARRAY_SIZE:3,MISC_FLAGS2:4},sm=1,im=2,rm=4,nm=64,am=512,om=131072,hm=827611204,lm=861165636,um=894720068,cm=808540228,dm=4,fm={[hm]:Ct.COMPRESSED_RGBA_S3TC_DXT1_EXT,[lm]:Ct.COMPRESSED_RGBA_S3TC_DXT3_EXT,[um]:Ct.COMPRESSED_RGBA_S3TC_DXT5_EXT},pm={70:Ct.COMPRESSED_RGBA_S3TC_DXT1_EXT,71:Ct.COMPRESSED_RGBA_S3TC_DXT1_EXT,73:Ct.COMPRESSED_RGBA_S3TC_DXT3_EXT,74:Ct.COMPRESSED_RGBA_S3TC_DXT3_EXT,76:Ct.COMPRESSED_RGBA_S3TC_DXT5_EXT,77:Ct.COMPRESSED_RGBA_S3TC_DXT5_EXT,72:Ct.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,75:Ct.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,78:Ct.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT};function Hl(i){const t=new Uint32Array(i);if(t[0]!==tm)throw new Error("Invalid DDS file magic word");const e=new Uint32Array(i,0,ir/Uint32Array.BYTES_PER_ELEMENT),s=e[rr.HEIGHT],r=e[rr.WIDTH],n=e[rr.MIPMAP_COUNT],a=new Uint32Array(i,rr.PIXEL_FORMAT*Uint32Array.BYTES_PER_ELEMENT,Jp/Uint32Array.BYTES_PER_ELEMENT),o=a[sm];if(o&rm){const h=a[em.FOURCC];if(h!==cm){const x=fm[h],v=sa+ir,b=new Uint8Array(i,v);return[new Ce(b,{format:x,width:r,height:s,levels:n})]}const l=sa+ir,u=new Uint32Array(t.buffer,l,$l/Uint32Array.BYTES_PER_ELEMENT),c=u[nr.DXGI_FORMAT],d=u[nr.RESOURCE_DIMENSION],f=u[nr.MISC_FLAG],p=u[nr.ARRAY_SIZE],m=pm[c];if(m===void 0)throw new Error(`DDSParser cannot parse texture data with DXGI format ${c}`);if(f===dm)throw new Error("DDSParser does not support cubemap textures");if(d===6)throw new Error("DDSParser does not supported 3D texture data");const g=new Array,_=sa+ir+$l;if(p===1)g.push(new Uint8Array(i,_));else{const x=js[m];let v=0,b=r,T=s;for(let w=0;w>>1,T=T>>>1}let R=_;for(let w=0;wnew Ce(x,{format:m,width:r,height:s,levels:n}))}throw o&nm?new Error("DDSParser does not support uncompressed texture data."):o&am?new Error("DDSParser does not supported YUV uncompressed texture data."):o&om?new Error("DDSParser does not support single-channel (lumninance) texture data!"):o&im?new Error("DDSParser does not support single-channel (alpha) texture data!"):new Error("DDSParser failed to load a texture file due to an unknown reason!")}const Vl=[171,75,84,88,32,49,49,187,13,10,26,10],mm=67305985,qt={FILE_IDENTIFIER:0,ENDIANNESS:12,GL_TYPE:16,GL_TYPE_SIZE:20,GL_FORMAT:24,GL_INTERNAL_FORMAT:28,GL_BASE_INTERNAL_FORMAT:32,PIXEL_WIDTH:36,PIXEL_HEIGHT:40,PIXEL_DEPTH:44,NUMBER_OF_ARRAY_ELEMENTS:48,NUMBER_OF_FACES:52,NUMBER_OF_MIPMAP_LEVELS:56,BYTES_OF_KEY_VALUE_DATA:60},ia=64,ra={[$.UNSIGNED_BYTE]:1,[$.UNSIGNED_SHORT]:2,[$.INT]:4,[$.UNSIGNED_INT]:4,[$.FLOAT]:4,[$.HALF_FLOAT]:8},jl={[M.RGBA]:4,[M.RGB]:3,[M.RG]:2,[M.RED]:1,[M.LUMINANCE]:1,[M.LUMINANCE_ALPHA]:2,[M.ALPHA]:1},Xl={[$.UNSIGNED_SHORT_4_4_4_4]:2,[$.UNSIGNED_SHORT_5_5_5_1]:2,[$.UNSIGNED_SHORT_5_6_5]:2};function zl(i,t,e=!1){const s=new DataView(t);if(!gm(i,s))return null;const r=s.getUint32(qt.ENDIANNESS,!0)===mm,n=s.getUint32(qt.GL_TYPE,r),a=s.getUint32(qt.GL_FORMAT,r),o=s.getUint32(qt.GL_INTERNAL_FORMAT,r),h=s.getUint32(qt.PIXEL_WIDTH,r),l=s.getUint32(qt.PIXEL_HEIGHT,r)||1,u=s.getUint32(qt.PIXEL_DEPTH,r)||1,c=s.getUint32(qt.NUMBER_OF_ARRAY_ELEMENTS,r)||1,d=s.getUint32(qt.NUMBER_OF_FACES,r),f=s.getUint32(qt.NUMBER_OF_MIPMAP_LEVELS,r),p=s.getUint32(qt.BYTES_OF_KEY_VALUE_DATA,r);if(l===0||u!==1)throw new Error("Only 2D textures are supported");if(d!==1)throw new Error("CubeTextures are not supported by KTXLoader yet!");if(c!==1)throw new Error("WebGL does not support array textures");const m=4,g=4,_=h+3&-4,x=l+3&-4,v=new Array(c);let b=h*l;n===0&&(b=_*x);let T;if(n!==0?ra[n]?T=ra[n]*jl[a]:T=Xl[n]:T=js[o],T===void 0)throw new Error("Unable to resolve the pixel format stored in the *.ktx file!");const R=e?vm(s,p,r):null;let w=b*T,A=h,S=l,I=_,H=x,B=ia+p;for(let E=0;E1||n!==0?A:I,levelHeight:f>1||n!==0?S:H,levelBuffer:new Uint8Array(t,V,w)},V+=w}B+=P+4,B=B%4!==0?B+4-B%4:B,A=A>>1||1,S=S>>1||1,I=A+m-1&~(m-1),H=S+g-1&~(g-1),w=I*H*T}return n!==0?{uncompressed:v.map(E=>{let P=E[0].levelBuffer,V=!1;return n===$.FLOAT?P=new Float32Array(E[0].levelBuffer.buffer,E[0].levelBuffer.byteOffset,E[0].levelBuffer.byteLength/4):n===$.UNSIGNED_INT?(V=!0,P=new Uint32Array(E[0].levelBuffer.buffer,E[0].levelBuffer.byteOffset,E[0].levelBuffer.byteLength/4)):n===$.INT&&(V=!0,P=new Int32Array(E[0].levelBuffer.buffer,E[0].levelBuffer.byteOffset,E[0].levelBuffer.byteLength/4)),{resource:new xs(P,{width:E[0].levelWidth,height:E[0].levelHeight}),type:n,format:V?_m(a):a}}),kvData:R}:{compressed:v.map(E=>new Ce(null,{format:o,width:h,height:l,levels:f,levelBuffers:E})),kvData:R}}function gm(i,t){for(let e=0;et-r){console.error("KTXLoader: keyAndValueByteSize out of bounds");break}let h=0;for(;ht in i?ym(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,Tm=(i,t)=>{for(var e in t||(t={}))xm.call(t,e)&&Yl(i,e,t[e]);if(Wl)for(var e of Wl(t))bm.call(t,e)&&Yl(i,e,t[e]);return i};const ql={extension:{type:D.LoadParser,priority:$t.High},name:"loadDDS",test(i){return _e(i,".dds")},async load(i,t,e){const s=await(await N.ADAPTER.fetch(i)).arrayBuffer(),r=Hl(s).map(n=>{const a=new X(n,Tm({mipmap:Ht.OFF,alphaMode:At.NO_PREMULTIPLIED_ALPHA,resolution:te(i)},t.data));return ts(a,e,i)});return r.length===1?r[0]:r},unload(i){Array.isArray(i)?i.forEach(t=>t.destroy(!0)):i.destroy(!0)}};U.add(ql);var Em=Object.defineProperty,Kl=Object.getOwnPropertySymbols,Am=Object.prototype.hasOwnProperty,wm=Object.prototype.propertyIsEnumerable,Zl=(i,t,e)=>t in i?Em(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,Sm=(i,t)=>{for(var e in t||(t={}))Am.call(t,e)&&Zl(i,e,t[e]);if(Kl)for(var e of Kl(t))wm.call(t,e)&&Zl(i,e,t[e]);return i};const Ql={extension:{type:D.LoadParser,priority:$t.High},name:"loadKTX",test(i){return _e(i,".ktx")},async load(i,t,e){const s=await(await N.ADAPTER.fetch(i)).arrayBuffer(),{compressed:r,uncompressed:n,kvData:a}=zl(i,s),o=r!=null?r:n,h=Sm({mipmap:Ht.OFF,alphaMode:At.NO_PREMULTIPLIED_ALPHA,resolution:te(i)},t.data),l=o.map(u=>{var c;o===n&&Object.assign(h,{type:u.type,format:u.format});const d=(c=u.resource)!=null?c:u,f=new X(d,h);return f.ktxKeyValueData=a,ts(f,e,i)});return l.length===1?l[0]:l},unload(i){Array.isArray(i)?i.forEach(t=>t.destroy(!0)):i.destroy(!0)}};U.add(Ql);const Jl={extension:D.ResolveParser,test:i=>{const t=i.split("?")[0].split(".").pop();return["basis","ktx","dds"].includes(t)},parse:i=>{var t,e,s,r;if(i.split("?")[0].split(".").pop()==="ktx"){const n=[".s3tc.ktx",".s3tc_sRGB.ktx",".etc.ktx",".etc1.ktx",".pvrt.ktx",".atc.ktx",".astc.ktx"];if(n.some(a=>i.endsWith(a)))return{resolution:parseFloat((e=(t=N.RETINA_PREFIX.exec(i))==null?void 0:t[1])!=null?e:"1"),format:n.find(a=>i.endsWith(a)),src:i}}return{resolution:parseFloat((r=(s=N.RETINA_PREFIX.exec(i))==null?void 0:s[1])!=null?r:"1"),format:i.split(".").pop(),src:i}}};U.add(Jl);const ar=new z,Cm=4,tu=class oi{constructor(t){this.renderer=t,this._rendererPremultipliedAlpha=!1}contextChange(){var t;const e=(t=this.renderer)==null?void 0:t.gl.getContextAttributes();this._rendererPremultipliedAlpha=!!(e&&e.alpha&&e.premultipliedAlpha)}async image(t,e,s,r){const n=new Image;return n.src=await this.base64(t,e,s,r),n}async base64(t,e,s,r){const n=this.canvas(t,r);if(n.toBlob!==void 0)return new Promise((a,o)=>{n.toBlob(h=>{if(!h){o(new Error("ICanvas.toBlob failed!"));return}const l=new FileReader;l.onload=()=>a(l.result),l.onerror=o,l.readAsDataURL(h)},e,s)});if(n.toDataURL!==void 0)return n.toDataURL(e,s);if(n.convertToBlob!==void 0){const a=await n.convertToBlob({type:e,quality:s});return new Promise((o,h)=>{const l=new FileReader;l.onload=()=>o(l.result),l.onerror=h,l.readAsDataURL(a)})}throw new Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(t,e){const{pixels:s,width:r,height:n,flipY:a,premultipliedAlpha:o}=this._rawPixels(t,e);a&&oi._flipY(s,r,n),o&&oi._unpremultiplyAlpha(s);const h=new ys(r,n,1),l=new ImageData(new Uint8ClampedArray(s.buffer),r,n);return h.context.putImageData(l,0,0),h.canvas}pixels(t,e){const{pixels:s,width:r,height:n,flipY:a,premultipliedAlpha:o}=this._rawPixels(t,e);return a&&oi._flipY(s,r,n),o&&oi._unpremultiplyAlpha(s),s}_rawPixels(t,e){const s=this.renderer;if(!s)throw new Error("The Extract has already been destroyed");let r,n=!1,a=!1,o,h=!1;t&&(t instanceof Yt?o=t:(o=s.generateTexture(t,{region:e,resolution:s.resolution,multisample:s.multisample}),h=!0,e&&(ar.width=e.width,ar.height=e.height,e=ar)));const l=s.gl;if(o){if(r=o.baseTexture.resolution,e=e!=null?e:o.frame,n=!1,a=o.baseTexture.alphaMode>0&&o.baseTexture.format===M.RGBA,!h){s.renderTexture.bind(o);const f=o.framebuffer.glFramebuffers[s.CONTEXT_UID];f.blitFramebuffer&&s.framebuffer.bind(f.blitFramebuffer)}}else r=s.resolution,e||(e=ar,e.width=s.width/r,e.height=s.height/r),n=!0,a=this._rendererPremultipliedAlpha,s.renderTexture.bind();const u=Math.max(Math.round(e.width*r),1),c=Math.max(Math.round(e.height*r),1),d=new Uint8Array(Cm*u*c);return l.readPixels(Math.round(e.x*r),Math.round(e.y*r),u,c,l.RGBA,l.UNSIGNED_BYTE,d),h&&(o==null||o.destroy(!0)),{pixels:d,width:u,height:c,flipY:n,premultipliedAlpha:a}}destroy(){this.renderer=null}static _flipY(t,e,s){const r=e<<2,n=s>>1,a=new Uint8Array(r);for(let o=0;o=0&&o>=0&&r>=0&&n>=0)){t.length=0;return}const h=Math.ceil(2.3*Math.sqrt(a+o)),l=h*8+(r?4:0)+(n?4:0);if(t.length=l,l===0)return;if(h===0){t.length=8,t[0]=t[6]=e+r,t[1]=t[3]=s+n,t[2]=t[4]=e-r,t[5]=t[7]=s-n;return}let u=0,c=h*4+(r?2:0)+2,d=c,f=l;{const p=r+a,m=n,g=e+p,_=e-p,x=s+m;if(t[u++]=g,t[u++]=x,t[--c]=x,t[--c]=_,n){const v=s-m;t[d++]=_,t[d++]=v,t[--f]=v,t[--f]=g}}for(let p=1;p0||t&&s<=0){const r=e/2;for(let n=r+r%2;n=6){su(e,!1);const a=[];for(let l=0;l=0&&n>=0&&a.push(e,s,e+r,s,e+r,s+n,e,s+n)},triangulate(i,t){const e=i.points,s=t.points;if(e.length===0)return;const r=s.length/2;s.push(e[0],e[1],e[2],e[3],e[6],e[7],e[4],e[5]),t.indices.push(r,r+1,r+2,r+1,r+2,r+3)}},ru={build(i){Xs.build(i)},triangulate(i,t){Xs.triangulate(i,t)}};var Mt=(i=>(i.MITER="miter",i.BEVEL="bevel",i.ROUND="round",i))(Mt||{}),ye=(i=>(i.BUTT="butt",i.ROUND="round",i.SQUARE="square",i))(ye||{});const Re={adaptive:!0,maxLength:10,minSegments:8,maxSegments:2048,epsilon:1e-4,_segmentsCount(i,t=20){if(!this.adaptive||!i||isNaN(i))return t;let e=Math.ceil(i/this.maxLength);return ethis.maxSegments&&(e=this.maxSegments),e}},Rm=Re;class aa{static curveTo(t,e,s,r,n,a){const o=a[a.length-2],h=a[a.length-1]-e,l=o-t,u=r-e,c=s-t,d=Math.abs(h*c-l*u);if(d<1e-8||n===0)return(a[a.length-2]!==t||a[a.length-1]!==e)&&a.push(t,e),null;const f=h*h+l*l,p=u*u+c*c,m=h*u+l*c,g=n*Math.sqrt(f)/d,_=n*Math.sqrt(p)/d,x=g*m/f,v=_*m/p,b=g*c+_*l,T=g*u+_*h,R=l*(_+x),w=h*(_+x),A=c*(g+v),S=u*(g+v),I=Math.atan2(w-T,R-b),H=Math.atan2(S-T,A-b);return{cx:b+t,cy:T+e,radius:n,startAngle:I,endAngle:H,anticlockwise:l*u>c*h}}static arc(t,e,s,r,n,a,o,h,l){const u=o-a,c=Re._segmentsCount(Math.abs(u)*n,Math.ceil(Math.abs(u)/Ts)*40),d=u/(c*2),f=d*2,p=Math.cos(d),m=Math.sin(d),g=c-1,_=g%1/g;for(let x=0;x<=g;++x){const v=x+_*x,b=d+a+f*v,T=Math.cos(b),R=-Math.sin(b);l.push((p*T+m*R)*n+s,(p*-R+m*T)*n+r)}}}class nu{constructor(){this.reset()}begin(t,e,s){this.reset(),this.style=t,this.start=e,this.attribStart=s}end(t,e){this.attribSize=e-this.attribStart,this.size=t-this.start}reset(){this.style=null,this.size=0,this.start=0,this.attribStart=0,this.attribSize=0}}class or{static curveLength(t,e,s,r,n,a,o,h){let l=0,u=0,c=0,d=0,f=0,p=0,m=0,g=0,_=0,x=0,v=0,b=t,T=e;for(let R=1;R<=10;++R)u=R/10,c=u*u,d=c*u,f=1-u,p=f*f,m=p*f,g=m*t+3*p*u*s+3*f*c*n+d*o,_=m*e+3*p*u*r+3*f*c*a+d*h,x=b-g,v=T-_,b=g,T=_,l+=Math.sqrt(x*x+v*v);return l}static curveTo(t,e,s,r,n,a,o){const h=o[o.length-2],l=o[o.length-1];o.length-=2;const u=Re._segmentsCount(or.curveLength(h,l,t,e,s,r,n,a));let c=0,d=0,f=0,p=0,m=0;o.push(h,l);for(let g=1,_=0;g<=u;++g)_=g/u,c=1-_,d=c*c,f=d*c,p=_*_,m=p*_,o.push(f*h+3*d*_*t+3*c*p*s+m*n,f*l+3*d*_*e+3*c*p*r+m*a)}}function au(i,t,e,s,r,n,a,o){const h=i-e*r,l=t-s*r,u=i+e*n,c=t+s*n;let d,f;a?(d=s,f=-e):(d=-s,f=e);const p=h+d,m=l+f,g=u+d,_=c+f;return o.push(p,m,g,_),2}function je(i,t,e,s,r,n,a,o){const h=e-i,l=s-t;let u=Math.atan2(h,l),c=Math.atan2(r-i,n-t);o&&uc&&(c+=Math.PI*2);let d=u;const f=c-u,p=Math.abs(f),m=Math.sqrt(h*h+l*l),g=(15*p*Math.sqrt(m)/Math.PI>>0)+1,_=f/g;if(d+=_,o){a.push(i,t,e,s);for(let x=1,v=d;x=0&&(n.join===Mt.ROUND?d+=je(v,b,v-w*E,b-A*E,v-S*E,b-I*E,u,!1)+4:d+=2,u.push(v-S*P,b-I*P,v+S*E,b+I*E));continue}const st=(-w+_)*(-A+b)-(-w+v)*(-A+x),et=(-S+T)*(-I+b)-(-S+v)*(-I+R),rt=(W*et-F*st)/Q,lt=(O*st-ht*et)/Q,_t=(rt-v)*(rt-v)+(lt-b)*(lt-b),nt=v+(rt-v)*E,ut=b+(lt-b)*E,mt=v-(rt-v)*P,vt=b-(lt-b)*P,ne=Math.min(W*W+ht*ht,F*F+O*O),ae=J?E:P,ii=ne+ae*ae*m,ug=_t<=ii;let vr=n.join;if(vr===Mt.MITER&&_t/m>g&&(vr=Mt.BEVEL),ug)switch(vr){case Mt.MITER:{u.push(nt,ut,mt,vt);break}case Mt.BEVEL:{J?u.push(nt,ut,v+w*P,b+A*P,nt,ut,v+S*P,b+I*P):u.push(v-w*E,b-A*E,mt,vt,v-S*E,b-I*E,mt,vt),d+=2;break}case Mt.ROUND:{J?(u.push(nt,ut,v+w*P,b+A*P),d+=je(v,b,v+w*P,b+A*P,v+S*P,b+I*P,u,!0)+4,u.push(nt,ut,v+S*P,b+I*P)):(u.push(v-w*E,b-A*E,mt,vt),d+=je(v,b,v-w*E,b-A*E,v-S*E,b-I*E,u,!1)+4,u.push(v-S*E,b-I*E,mt,vt));break}}else{switch(u.push(v-w*E,b-A*E,v+w*P,b+A*P),vr){case Mt.MITER:{J?u.push(mt,vt,mt,vt):u.push(nt,ut,nt,ut),d+=2;break}case Mt.ROUND:{J?d+=je(v,b,v+w*P,b+A*P,v+S*P,b+I*P,u,!0)+2:d+=je(v,b,v-w*E,b-A*E,v-S*E,b-I*E,u,!1)+2;break}}u.push(v-S*E,b-I*E,v+S*P,b+I*P),d+=2}}_=s[(c-2)*2],x=s[(c-2)*2+1],v=s[(c-1)*2],b=s[(c-1)*2+1],w=-(x-b),A=_-v,H=Math.sqrt(w*w+A*A),w/=H,A/=H,w*=p,A*=p,u.push(v-w*E,b-A*E,v+w*P,b+A*P),h||(n.cap===ye.ROUND?d+=je(v-w*(E-P)*.5,b-A*(E-P)*.5,v-w*E,b-A*E,v+w*P,b+A*P,u,!1)+2:n.cap===ye.SQUARE&&(d+=au(v,b,w,A,E,P,!1,u)));const V=t.indices,q=Re.epsilon*Re.epsilon;for(let j=f;j0&&(this.invalidate(),this.clearDirty++,this.graphicsData.length=0),this}drawShape(t,e=null,s=null,r=null){const n=new Ws(t,e,s,r);return this.graphicsData.push(n),this.dirty++,this}drawHole(t,e=null){if(!this.graphicsData.length)return null;const s=new Ws(t,null,null,e),r=this.graphicsData[this.graphicsData.length-1];return s.lineStyle=r.lineStyle,r.holes.push(s),this.dirty++,this}destroy(){super.destroy();for(let t=0;t0&&(s=this.batches[this.batches.length-1],r=s.style);for(let h=this.shapeIndex;h65535;this.indicesUint16&&this.indices.length===this.indicesUint16.length&&o===this.indicesUint16.BYTES_PER_ELEMENT>2?this.indicesUint16.set(this.indices):this.indicesUint16=o?new Uint32Array(this.indices):new Uint16Array(this.indices),this.batchable=this.isBatchable(),this.batchable?this.packBatches():this.buildDrawCalls()}_compareStyles(t,e){return!(!t||!e||t.texture.baseTexture!==e.texture.baseTexture||t.color+t.alpha!==e.color+e.alpha||!!t.native!=!!e.native)}validateBatching(){if(this.dirty===this.cacheDirty||!this.graphicsData.length)return!1;for(let t=0,e=this.graphicsData.length;t65535*2)return!1;const t=this.batches;for(let e=0;e0&&(r=zs.pop(),r||(r=new Ai,r.texArray=new Bi),this.drawCalls.push(r)),r.start=u,r.size=0,r.texArray.count=0,r.type=l),m.touched=1,m._batchEnabled=t,m._batchLocation=n,m.wrapMode=Zt.REPEAT,r.texArray.elements[r.texArray.count++]=m,n++)),r.size+=d.size,u+=d.size,o=m._batchLocation,this.addColors(e,p.color,p.alpha,d.attribSize,d.attribStart),this.addTextureIds(s,o,d.attribSize,d.attribStart)}X._globalBatch=t,this.packAttributes()}packAttributes(){const t=this.points,e=this.uvs,s=this.colors,r=this.textureIds,n=new ArrayBuffer(t.length*3*4),a=new Float32Array(n),o=new Uint32Array(n);let h=0;for(let l=0;l0&&t.alpha>0;return s?(t.matrix&&(t.matrix=t.matrix.clone(),t.matrix.invert()),Object.assign(this._lineStyle,{visible:s},t)):this._lineStyle.reset(),this}startPoly(){if(this.currentPath){const t=this.currentPath.points,e=this.currentPath.points.length;e>2&&(this.drawShape(this.currentPath),this.currentPath=new Be,this.currentPath.closeStroke=!1,this.currentPath.points.push(t[e-2],t[e-1]))}else this.currentPath=new Be,this.currentPath.closeStroke=!1}finishPoly(){this.currentPath&&(this.currentPath.points.length>2?(this.drawShape(this.currentPath),this.currentPath=null):this.currentPath.points.length=0)}moveTo(t,e){return this.startPoly(),this.currentPath.points[0]=t,this.currentPath.points[1]=e,this}lineTo(t,e){this.currentPath||this.moveTo(0,0);const s=this.currentPath.points,r=s[s.length-2],n=s[s.length-1];return(r!==t||n!==e)&&s.push(t,e),this}_initCurve(t=0,e=0){this.currentPath?this.currentPath.points.length===0&&(this.currentPath.points=[t,e]):this.moveTo(t,e)}quadraticCurveTo(t,e,s,r){this._initCurve();const n=this.currentPath.points;return n.length===0&&this.moveTo(0,0),hr.curveTo(t,e,s,r,n),this}bezierCurveTo(t,e,s,r,n,a){return this._initCurve(),or.curveTo(t,e,s,r,n,a,this.currentPath.points),this}arcTo(t,e,s,r,n){this._initCurve(t,e);const a=this.currentPath.points,o=aa.curveTo(t,e,s,r,n,a);if(o){const{cx:h,cy:l,radius:u,startAngle:c,endAngle:d,anticlockwise:f}=o;this.arc(h,l,u,c,d,f)}return this}arc(t,e,s,r,n,a=!1){if(r===n)return this;if(!a&&n<=r?n+=Ts:a&&r<=n&&(r+=Ts),n-r===0)return this;const o=t+Math.cos(r)*s,h=e+Math.sin(r)*s,l=this._geometry.closePointEps;let u=this.currentPath?this.currentPath.points:null;if(u){const c=Math.abs(u[u.length-2]-o),d=Math.abs(u[u.length-1]-h);c0;return s?(t.matrix&&(t.matrix=t.matrix.clone(),t.matrix.invert()),Object.assign(this._fillStyle,{visible:s},t)):this._fillStyle.reset(),this}endFill(){return this.finishPoly(),this._fillStyle.reset(),this}drawRect(t,e,s,r){return this.drawShape(new z(t,e,s,r))}drawRoundedRect(t,e,s,r,n){return this.drawShape(new Ri(t,e,s,r,n))}drawCircle(t,e,s){return this.drawShape(new Si(t,e,s))}drawEllipse(t,e,s,r){return this.drawShape(new Ci(t,e,s,r))}drawPolygon(...t){let e,s=!0;const r=t[0];r.points?(s=r.closeStroke,e=r.points):Array.isArray(t[0])?e=t[0]:e=t;const n=new Be(e);return n.closeStroke=s,this.drawShape(n),this}drawShape(t){return this._holeMode?this._geometry.drawHole(t,this._matrix):this._geometry.drawShape(t,this._fillStyle.clone(),this._lineStyle.clone(),this._matrix),this}clear(){return this._geometry.clear(),this._lineStyle.reset(),this._fillStyle.reset(),this._boundsID++,this._matrix=null,this._holeMode=!1,this.currentPath=null,this}isFastRect(){const t=this._geometry.graphicsData;return t.length===1&&t[0].shape.type===it.RECT&&!t[0].matrix&&!t[0].holes.length&&!(t[0].lineStyle.visible&&t[0].lineStyle.width)}_render(t){this.finishPoly();const e=this._geometry;e.updateBatches(),e.batchable?(this.batchDirty!==e.batchDirty&&this._populateBatches(),this._renderBatched(t)):(t.batch.flush(),this._renderDirect(t))}_populateBatches(){const t=this._geometry,e=this.blendMode,s=t.batches.length;this.batchTint=-1,this._transformID=-1,this.batchDirty=t.batchDirty,this.batches.length=s,this.vertexData=new Float32Array(t.points);for(let r=0;r0){const p=h.x-t[d].x,m=h.y-t[d].y,g=Math.sqrt(p*p+m*m);h=t[d],o+=g/l}else o=d/(u-1);n[f]=o,n[f+1]=0,n[f+2]=o,n[f+3]=1}let c=0;for(let d=0;d0?this.textureScale*this._width/2:this._width/2;for(let l=0;l1&&(d=1);const f=Math.sqrt(r*r+n*n);f<1e-6?(r=0,n=0):(r/=f,n/=f,r*=h,n*=h),a[c]=u.x+r,a[c+1]=u.y+n,a[c+2]=u.x-r,a[c+3]=u.y-n,e=u}this.buffers[0].update()}update(){this.textureScale>0?this.build():this.updateVertices()}}class pu extends Et{constructor(t,e,s){const r=new du(t.width,t.height,e,s),n=new Xe(L.WHITE);super(r,n),this.texture=t,this.autoResize=!0}textureUpdated(){this._textureID=this.shader.texture._updateID;const t=this.geometry,{width:e,height:s}=this.shader.texture;this.autoResize&&(t.width!==e||t.height!==s)&&(t.width=this.shader.texture.width,t.height=this.shader.texture.height,t.build())}set texture(t){this.shader.texture!==t&&(this.shader.texture=t,this._textureID=-1,t.baseTexture.valid?this.textureUpdated():t.once("update",this.textureUpdated,this))}get texture(){return this.shader.texture}_render(t){this._textureID!==this.shader.texture._updateID&&this.textureUpdated(),super._render(t)}destroy(t){this.shader.texture.off("update",this.textureUpdated,this),super.destroy(t)}}const cr=10;class Ks extends pu{constructor(t,e,s,r,n){var a,o,h,l,u,c,d,f;super(L.WHITE,4,4),this._origWidth=t.orig.width,this._origHeight=t.orig.height,this._width=this._origWidth,this._height=this._origHeight,this._leftWidth=(o=e!=null?e:(a=t.defaultBorders)==null?void 0:a.left)!=null?o:cr,this._rightWidth=(l=r!=null?r:(h=t.defaultBorders)==null?void 0:h.right)!=null?l:cr,this._topHeight=(c=s!=null?s:(u=t.defaultBorders)==null?void 0:u.top)!=null?c:cr,this._bottomHeight=(f=n!=null?n:(d=t.defaultBorders)==null?void 0:d.bottom)!=null?f:cr,this.texture=t}textureUpdated(){this._textureID=this.shader.texture._updateID,this._refresh()}get vertices(){return this.geometry.getBuffer("aVertexPosition").data}set vertices(t){this.geometry.getBuffer("aVertexPosition").data=t}updateHorizontalVertices(){const t=this.vertices,e=this._getMinScale();t[9]=t[11]=t[13]=t[15]=this._topHeight*e,t[17]=t[19]=t[21]=t[23]=this._height-this._bottomHeight*e,t[25]=t[27]=t[29]=t[31]=this._height}updateVerticalVertices(){const t=this.vertices,e=this._getMinScale();t[2]=t[10]=t[18]=t[26]=this._leftWidth*e,t[4]=t[12]=t[20]=t[28]=this._width-this._rightWidth*e,t[6]=t[14]=t[22]=t[30]=this._width}_getMinScale(){const t=this._leftWidth+this._rightWidth,e=this._width>t?1:this._width/t,s=this._topHeight+this._bottomHeight,r=this._height>s?1:this._height/s;return Math.min(e,r)}get width(){return this._width}set width(t){this._width=t,this._refresh()}get height(){return this._height}set height(t){this._height=t,this._refresh()}get leftWidth(){return this._leftWidth}set leftWidth(t){this._leftWidth=t,this._refresh()}get rightWidth(){return this._rightWidth}set rightWidth(t){this._rightWidth=t,this._refresh()}get topHeight(){return this._topHeight}set topHeight(t){this._topHeight=t,this._refresh()}get bottomHeight(){return this._bottomHeight}set bottomHeight(t){this._bottomHeight=t,this._refresh()}_refresh(){const t=this.texture,e=this.geometry.buffers[1].data;this._origWidth=t.orig.width,this._origHeight=t.orig.height;const s=1/this._origWidth,r=1/this._origHeight;e[0]=e[8]=e[16]=e[24]=0,e[1]=e[3]=e[5]=e[7]=0,e[6]=e[14]=e[22]=e[30]=1,e[25]=e[27]=e[29]=e[31]=1,e[2]=e[10]=e[18]=e[26]=s*this._leftWidth,e[4]=e[12]=e[20]=e[28]=1-s*this._rightWidth,e[9]=e[11]=e[13]=e[15]=r*this._topHeight,e[17]=e[19]=e[21]=e[23]=1-r*this._bottomHeight,this.updateHorizontalVertices(),this.updateVerticalVertices(),this.geometry.buffers[0].update(),this.geometry.buffers[1].update()}}class mu extends Et{constructor(t=L.EMPTY,e,s,r,n){const a=new qs(e,s,r);a.getBuffer("aVertexPosition").static=!1;const o=new Xe(t);super(a,o,null,n),this.autoUpdate=!0}get vertices(){return this.geometry.getBuffer("aVertexPosition").data}set vertices(t){this.geometry.getBuffer("aVertexPosition").data=t}_render(t){this.autoUpdate&&this.geometry.getBuffer("aVertexPosition").update(),super._render(t)}}class gu extends Et{constructor(t,e,s=0){const r=new fu(t.height,e,s),n=new Xe(t);s>0&&(t.baseTexture.wrapMode=Zt.REPEAT),super(r,n),this.autoUpdate=!0}_render(t){const e=this.geometry;(this.autoUpdate||e._width!==this.shader.texture.height)&&(e._width=this.shader.texture.height,e.update()),super._render(t)}}class _u{constructor(t){this.maxItemsPerFrame=t,this.itemsLeft=0}beginFrame(){this.itemsLeft=this.maxItemsPerFrame}allowedToUpload(){return this.itemsLeft-- >0}}function Bm(i,t){var e;let s=!1;if((e=i==null?void 0:i._textures)!=null&&e.length){for(let r=0;r{this.queue&&this.prepareItems()},this.registerFindHook(km),this.registerFindHook(Gm),this.registerFindHook(Bm),this.registerFindHook(Fm),this.registerFindHook(Nm),this.registerUploadHook(Lm),this.registerUploadHook(Um)}upload(t){return new Promise(e=>{t&&this.add(t),this.queue.length?(this.completes.push(e),this.ticking||(this.ticking=!0,xt.system.addOnce(this.tick,this,pe.UTILITY))):e()})}tick(){setTimeout(this.delayedTick,0)}prepareItems(){for(this.limiter.beginFrame();this.queue.length&&this.limiter.allowedToUpload();){const t=this.queue[0];let e=!1;if(t&&!t._destroyed){for(let s=0,r=this.uploadHooks.length;s=0;e--)this.add(t.children[e]);return this}destroy(){this.ticking&&xt.system.remove(this.tick,this),this.ticking=!1,this.addHooks=null,this.uploadHooks=null,this.renderer=null,this.completes=null,this.queue=null,this.limiter=null,this.uploadHookHelper=null}};vu.uploadsPerFrame=4;let Zs=vu;Object.defineProperties(N,{UPLOADS_PER_FRAME:{get(){return Zs.uploadsPerFrame},set(i){Zs.uploadsPerFrame=i}}});function yu(i,t){return t instanceof X?(t._glTextures[i.CONTEXT_UID]||i.texture.bind(t),!0):!1}function $m(i,t){if(!(t instanceof rs))return!1;const{geometry:e}=t;t.finishPoly(),e.updateBatches();const{batches:s}=e;for(let r=0;r=this._durations[this.currentFrame];)r-=this._durations[this.currentFrame]*n,this._currentTime+=n;this._currentTime+=r/this._durations[this.currentFrame]}else this._currentTime+=e;this._currentTime<0&&!this.loop?(this.gotoAndStop(0),this.onComplete&&this.onComplete()):this._currentTime>=this._textures.length&&!this.loop?(this.gotoAndStop(this._textures.length-1),this.onComplete&&this.onComplete()):s!==this.currentFrame&&(this.loop&&this.onLoop&&(this.animationSpeed>0&&this.currentFrames)&&this.onLoop(),this.updateTexture())}updateTexture(){const t=this.currentFrame;this._previousFrame!==t&&(this._previousFrame=t,this._texture=this._textures[t],this._textureID=-1,this._textureTrimmedID=-1,this._cachedTint=16777215,this.uvs=this._texture._uvs.uvsFloat32,this.updateAnchor&&this._anchor.copyFrom(this._texture.defaultAnchor),this.onFrameChange&&this.onFrameChange(this.currentFrame))}destroy(t){this.stop(),super.destroy(t),this.onComplete=null,this.onFrameChange=null,this.onLoop=null}static fromFrames(t){const e=[];for(let s=0;sthis.totalFrames-1)throw new Error(`[AnimatedSprite]: Invalid frame index value ${t}, expected to be between 0 and totalFrames ${this.totalFrames}.`);const e=this.currentFrame;this._currentTime=t,e!==this.currentFrame&&this.updateTexture()}get playing(){return this._playing}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,!this._autoUpdate&&this._isConnectedToTicker?(xt.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(xt.shared.add(this.update,this),this._isConnectedToTicker=!0))}}const xu=class hi{constructor(t,e,s=null){this.linkedSheets=[],this._texture=t instanceof L?t:null,this.baseTexture=t instanceof X?t:this._texture.baseTexture,this.textures={},this.animations={},this.data=e;const r=this.baseTexture.resource;this.resolution=this._updateResolution(s||(r?r.url:null)),this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}_updateResolution(t=null){const{scale:e}=this.data.meta;let s=te(t,null);return s===null&&(s=parseFloat(e!=null?e:"1")),s!==1&&this.baseTexture.setResolution(s),s}parse(){return new Promise(t=>{this._callback=t,this._batchIndex=0,this._frameKeys.length<=hi.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;const s=hi.BATCH_SIZE;for(;e-t{this._batchIndex*hi.BATCH_SIZE{s[r]=t}),Object.keys(t.textures).forEach(r=>{s[r]=t.textures[r]}),!e){const r=bt.dirname(i[0]);t.linkedSheets.forEach((n,a)=>{const o=bu([`${r}/${t.data.meta.related_multi_packs[a]}`],n,!0);Object.assign(s,o)})}return s}const Tu={extension:D.Asset,cache:{test:i=>i instanceof fa,getCacheableAssets:(i,t)=>bu(i,t,!1)},resolver:{test:i=>{const t=i.split("?")[0].split("."),e=t.pop(),s=t.pop();return e==="json"&&jm.includes(s)},parse:i=>{var t,e;const s=i.split(".");return{resolution:parseFloat((e=(t=N.RETINA_PREFIX.exec(i))==null?void 0:t[1])!=null?e:"1"),format:s[s.length-2],src:i}}},loader:{name:"spritesheetLoader",extension:{type:D.LoadParser,priority:$t.Normal},async testParse(i,t){return bt.extname(t.src).toLowerCase()===".json"&&!!i.frames},async parse(i,t,e){var s,r;let n=bt.dirname(t.src);n&&n.lastIndexOf("/")!==n.length-1&&(n+="/");let a=n+i.meta.image;a=sr(a,t.src);const o=(await e.load([a]))[a],h=new fa(o.baseTexture,i,t.src);await h.parse();const l=(s=i==null?void 0:i.meta)==null?void 0:s.related_multi_packs;if(Array.isArray(l)){const u=[];for(const d of l){if(typeof d!="string")continue;let f=n+d;(r=t.data)!=null&&r.ignoreMultiPack||(f=sr(f,t.src),u.push(e.load({src:f,data:{ignoreMultiPack:!0}})))}const c=await Promise.all(u);h.linkedSheets=c,c.forEach(d=>{d.linkedSheets=[h].concat(h.linkedSheets.filter(f=>f!==d))})}return h},unload(i){i.destroy(!0)}}};U.add(Tu);class Qs{constructor(){this.info=[],this.common=[],this.page=[],this.char=[],this.kerning=[],this.distanceField=[]}}class Js{static test(t){return typeof t=="string"&&t.startsWith("info face=")}static parse(t){const e=t.match(/^[a-z]+\s+.+$/gm),s={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const n in e){const a=e[n].match(/^[a-z]+/gm)[0],o=e[n].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),h={};for(const l in o){const u=o[l].split("="),c=u[0],d=u[1].replace(/"/gm,""),f=parseFloat(d),p=isNaN(f)?d:f;h[c]=p}s[a].push(h)}const r=new Qs;return s.info.forEach(n=>r.info.push({face:n.face,size:parseInt(n.size,10)})),s.common.forEach(n=>r.common.push({lineHeight:parseInt(n.lineHeight,10)})),s.page.forEach(n=>r.page.push({id:parseInt(n.id,10),file:n.file})),s.char.forEach(n=>r.char.push({id:parseInt(n.id,10),page:parseInt(n.page,10),x:parseInt(n.x,10),y:parseInt(n.y,10),width:parseInt(n.width,10),height:parseInt(n.height,10),xoffset:parseInt(n.xoffset,10),yoffset:parseInt(n.yoffset,10),xadvance:parseInt(n.xadvance,10)})),s.kerning.forEach(n=>r.kerning.push({first:parseInt(n.first,10),second:parseInt(n.second,10),amount:parseInt(n.amount,10)})),s.distanceField.forEach(n=>r.distanceField.push({distanceRange:parseInt(n.distanceRange,10),fieldType:n.fieldType})),r}}class fr{static test(t){const e=t;return typeof t!="string"&&"getElementsByTagName"in t&&e.getElementsByTagName("page").length&&e.getElementsByTagName("info")[0].getAttribute("face")!==null}static parse(t){const e=new Qs,s=t.getElementsByTagName("info"),r=t.getElementsByTagName("common"),n=t.getElementsByTagName("page"),a=t.getElementsByTagName("char"),o=t.getElementsByTagName("kerning"),h=t.getElementsByTagName("distanceField");for(let l=0;l")?fr.test(N.ADAPTER.parseXML(t)):!1}static parse(t){return fr.parse(N.ADAPTER.parseXML(t))}}const pa=[Js,fr,pr];function Eu(i){for(let t=0;tt in i?Ym(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,qm=(i,t)=>{for(var e in t||(t={}))wu.call(t,e)&&Cu(i,e,t[e]);if(gr)for(var e of gr(t))Su.call(t,e)&&Cu(i,e,t[e]);return i},Km=(i,t)=>{var e={};for(var s in i)wu.call(i,s)&&t.indexOf(s)<0&&(e[s]=i[s]);if(i!=null&&gr)for(var s of gr(i))t.indexOf(s)<0&&Su.call(i,s)&&(e[s]=i[s]);return e};const Ie=class oe{constructor(t,e,s){var r,n;const[a]=t.info,[o]=t.common,[h]=t.page,[l]=t.distanceField,u=te(h.file),c={};this._ownsTextures=s,this.font=a.face,this.size=a.size,this.lineHeight=o.lineHeight/u,this.chars={},this.pageTextures=c;for(let d=0;d=l-B*o){if(g===0)throw new Error(`[BitmapFont] textureHeight ${l}px is too small (fontFamily: '${d.fontFamily}', fontSize: ${d.fontSize}px, char: '${S}')`);--A,_=null,x=null,v=null,g=0,m=0,b=0;continue}if(b=Math.max(B+I.fontProperties.descent,b),E*o+m>=f){if(m===0)throw new Error(`[BitmapFont] textureWidth ${h}px is too small (fontFamily: '${d.fontFamily}', fontSize: ${d.fontSize}px, char: '${S}')`);--A,g+=b*o,g=Math.ceil(g),m=0,b=0;continue}zm(_,x,I,m,g,o,d);const P=mr(I.text);p.char.push({id:P,page:R.length-1,x:m/o,y:g/o,width:E,height:B,xoffset:0,yoffset:0,xadvance:H-(d.dropShadow?d.dropShadowDistance:0)-(d.stroke?d.strokeThickness:0)}),m+=(E+2*a)*o,m=Math.ceil(m)}if(!(s!=null&&s.skipKerning))for(let A=0,S=c.length;A 0.99) {\r + alpha = 1.0;\r + }\r +\r + // Gamma correction for coverage-like alpha\r + float luma = dot(uColor.rgb, vec3(0.299, 0.587, 0.114));\r + float gamma = mix(1.0, 1.0 / 2.2, luma);\r + float coverage = pow(uColor.a * alpha, gamma); \r +\r + // NPM Textures, NPM outputs\r + gl_FragColor = vec4(uColor.rgb, coverage);\r +}\r +`,Qm=`// Mesh material default fragment\r +attribute vec2 aVertexPosition;\r +attribute vec2 aTextureCoord;\r +\r +uniform mat3 projectionMatrix;\r +uniform mat3 translationMatrix;\r +uniform mat3 uTextureMatrix;\r +\r +varying vec2 vTextureCoord;\r +\r +void main(void)\r +{\r + gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\r +\r + vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy;\r +}\r +`;const Ru=[],Iu=[],Pu=[],Mu=class $u extends St{constructor(t,e={}){super();const{align:s,tint:r,maxWidth:n,letterSpacing:a,fontName:o,fontSize:h}=Object.assign({},$u.styleDefaults,e);if(!xe.available[o])throw new Error(`Missing BitmapFont "${o}"`);this._activePagesMeshData=[],this._textWidth=0,this._textHeight=0,this._align=s,this._tintColor=new Y(r),this._font=void 0,this._fontName=o,this._fontSize=h,this.text=t,this._maxWidth=n,this._maxLineHeight=0,this._letterSpacing=a,this._anchor=new de(()=>{this.dirty=!0},this,0,0),this._roundPixels=N.ROUND_PIXELS,this.dirty=!0,this._resolution=N.RESOLUTION,this._autoResolution=!0,this._textureCache={}}updateText(){var t;const e=xe.available[this._fontName],s=this.fontSize,r=s/e.size,n=new K,a=[],o=[],h=[],l=this._text.replace(/(?:\r\n|\r)/g,` +`)||" ",u=Au(l),c=this._maxWidth*e.size/s,d=e.distanceFieldType==="none"?Ru:Iu;let f=null,p=0,m=0,g=0,_=-1,x=0,v=0,b=0,T=0;for(let B=0;B0&&n.x>c&&(++v,Oe(a,1+_-v,1+B-_),B=_,_=-1,o.push(x),h.push(a.length>0?a[a.length-1].prevSpaces:0),m=Math.max(m,x),g++,n.x=0,n.y+=e.lineHeight,f=null,T=0)}const R=u[u.length-1];R!=="\r"&&R!==` +`&&(/(?:\s)/.test(R)&&(p=x),o.push(p),m=Math.max(m,p),h.push(-1));const w=[];for(let B=0;B<=g;B++){let E=0;this._align==="right"?E=m-o[B]:this._align==="center"?E=(m-o[B])/2:this._align==="justify"&&(E=h[B]<0?0:(m-o[B])/h[B]),w.push(E)}const A=a.length,S={},I=[],H=this._activePagesMeshData;d.push(...H);for(let B=0;B6*P)||E.vertices.lengthe[r.mesh.texture.baseTexture.uid]).forEach(r=>{r.mesh.texture=L.EMPTY});for(const r in e)e[r].destroy(),delete e[r];this._font=null,this._tintColor=null,this._textureCache=null,super.destroy(t)}};Mu.styleDefaults={align:"left",tint:16777215,maxWidth:0,letterSpacing:0};let Jm=Mu;const tg=[".xml",".fnt"],Du={extension:{type:D.LoadParser,priority:$t.Normal},name:"loadBitmapFont",test(i){return tg.includes(bt.extname(i).toLowerCase())},async testParse(i){return Js.test(i)||pr.test(i)},async parse(i,t,e){const s=Js.test(i)?Js.parse(i):pr.parse(i),{src:r}=t,{page:n}=s,a=[];for(let l=0;lo[l]);return xe.install(s,h,!0)},async load(i,t){return(await N.ADAPTER.fetch(i)).text()},unload(i){i.destroy()}};U.add(Du);var eg=Object.defineProperty,sg=Object.defineProperties,ig=Object.getOwnPropertyDescriptors,Ou=Object.getOwnPropertySymbols,rg=Object.prototype.hasOwnProperty,ng=Object.prototype.propertyIsEnumerable,Bu=(i,t,e)=>t in i?eg(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,ag=(i,t)=>{for(var e in t||(t={}))rg.call(t,e)&&Bu(i,e,t[e]);if(Ou)for(var e of Ou(t))ng.call(t,e)&&Bu(i,e,t[e]);return i},og=(i,t)=>sg(i,ig(t));const ma=class os extends ge{constructor(){super(...arguments),this._fonts=[],this._overrides=[],this._stylesheet="",this.fontsDirty=!1}static from(t){return new os(Object.keys(os.defaultOptions).reduce((e,s)=>og(ag({},e),{[s]:t[s]}),{}))}cleanFonts(){this._fonts.length>0&&(this._fonts.forEach(t=>{URL.revokeObjectURL(t.src),t.refs--,t.refs===0&&(t.fontFace&&document.fonts.delete(t.fontFace),delete os.availableFonts[t.originalUrl])}),this.fontFamily="Arial",this._fonts.length=0,this.styleID++,this.fontsDirty=!0)}loadFont(t,e={}){const{availableFonts:s}=os;if(s[t]){const r=s[t];return this._fonts.push(r),r.refs++,this.styleID++,this.fontsDirty=!0,Promise.resolve()}return N.ADAPTER.fetch(t).then(r=>r.blob()).then(async r=>new Promise((n,a)=>{const o=URL.createObjectURL(r),h=new FileReader;h.onload=()=>n([o,h.result]),h.onerror=a,h.readAsDataURL(r)})).then(async([r,n])=>{const a=Object.assign({family:bt.basename(t,bt.extname(t)),weight:"normal",style:"normal",display:"auto",src:r,dataSrc:n,refs:1,originalUrl:t,fontFace:null},e);s[t]=a,this._fonts.push(a),this.styleID++;const o=new FontFace(a.family,`url(${a.src})`,{weight:a.weight,style:a.style,display:a.display});a.fontFace=o,await o.load(),document.fonts.add(o),await document.fonts.ready,this.styleID++,this.fontsDirty=!0})}addOverride(...t){const e=t.filter(s=>!this._overrides.includes(s));e.length>0&&(this._overrides.push(...e),this.styleID++)}removeOverride(...t){const e=t.filter(s=>this._overrides.includes(s));e.length>0&&(this._overrides=this._overrides.filter(s=>!e.includes(s)),this.styleID++)}toCSS(t){return[`transform: scale(${t})`,"transform-origin: top left","display: inline-block",`color: ${this.normalizeColor(this.fill)}`,`font-size: ${this.fontSize}px`,`font-family: ${this.fontFamily}`,`font-weight: ${this.fontWeight}`,`font-style: ${this.fontStyle}`,`font-variant: ${this.fontVariant}`,`letter-spacing: ${this.letterSpacing}px`,`text-align: ${this.align}`,`padding: ${this.padding}px`,`white-space: ${this.whiteSpace}`,...this.lineHeight?[`line-height: ${this.lineHeight}px`]:[],...this.wordWrap?[`word-wrap: ${this.breakWords?"break-all":"break-word"}`,`max-width: ${this.wordWrapWidth}px`]:[],...this.strokeThickness?[`-webkit-text-stroke-width: ${this.strokeThickness}px`,`-webkit-text-stroke-color: ${this.normalizeColor(this.stroke)}`,`text-stroke-width: ${this.strokeThickness}px`,`text-stroke-color: ${this.normalizeColor(this.stroke)}`,"paint-order: stroke"]:[],...this.dropShadow?[this.dropShadowToCSS()]:[],...this._overrides].join(";")}toGlobalCSS(){return this._fonts.reduce((t,e)=>`${t} + @font-face { + font-family: "${e.family}"; + src: url('${e.dataSrc}'); + font-weight: ${e.weight}; + font-style: ${e.style}; + font-display: ${e.display}; + }`,this._stylesheet)}get stylesheet(){return this._stylesheet}set stylesheet(t){this._stylesheet!==t&&(this._stylesheet=t,this.styleID++)}normalizeColor(t){return Array.isArray(t)&&(t=To(t)),typeof t=="number"?bo(t):t}dropShadowToCSS(){let t=this.normalizeColor(this.dropShadowColor);const e=this.dropShadowAlpha,s=Math.round(Math.cos(this.dropShadowAngle)*this.dropShadowDistance),r=Math.round(Math.sin(this.dropShadowAngle)*this.dropShadowDistance);t.startsWith("#")&&e<1&&(t+=(e*255|0).toString(16).padStart(2,"0"));const n=`${s}px ${r}px`;return this.dropShadowBlur>0?`text-shadow: ${n} ${this.dropShadowBlur}px ${t}`:`text-shadow: ${n} ${t}`}reset(){Object.assign(this,os.defaultOptions)}onBeforeDraw(){const{fontsDirty:t}=this;return this.fontsDirty=!1,this.isSafari&&this._fonts.length>0&&t?new Promise(e=>setTimeout(e,100)):Promise.resolve()}get isSafari(){const{userAgent:t}=N.ADAPTER.getNavigator();return/^((?!chrome|android).)*safari/i.test(t)}set fillGradientStops(t){console.warn("[HTMLTextStyle] fillGradientStops is not supported by HTMLText")}get fillGradientStops(){return super.fillGradientStops}set fillGradientType(t){console.warn("[HTMLTextStyle] fillGradientType is not supported by HTMLText")}get fillGradientType(){return super.fillGradientType}set miterLimit(t){console.warn("[HTMLTextStyle] miterLimit is not supported by HTMLText")}get miterLimit(){return super.miterLimit}set trim(t){console.warn("[HTMLTextStyle] trim is not supported by HTMLText")}get trim(){return super.trim}set textBaseline(t){console.warn("[HTMLTextStyle] textBaseline is not supported by HTMLText")}get textBaseline(){return super.textBaseline}set leading(t){console.warn("[HTMLTextStyle] leading is not supported by HTMLText")}get leading(){return super.leading}set lineJoin(t){console.warn("[HTMLTextStyle] lineJoin is not supported by HTMLText")}get lineJoin(){return super.lineJoin}};ma.availableFonts={},ma.defaultOptions={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",letterSpacing:0,lineHeight:0,padding:0,stroke:"black",strokeThickness:0,whiteSpace:"normal",wordWrap:!1,wordWrapWidth:100};let _r=ma;const ti=class hs extends Ut{constructor(t="",e={}){var s;super(L.EMPTY),this._text=null,this._style=null,this._autoResolution=!0,this.localStyleID=-1,this.dirty=!1,this._updateID=0,this.ownsStyle=!1;const r=new Image,n=L.from(r,{scaleMode:N.SCALE_MODE,resourceOptions:{autoLoad:!1}});n.orig=new z,n.trim=new z,this.texture=n;const a="http://www.w3.org/2000/svg",o="http://www.w3.org/1999/xhtml",h=document.createElementNS(a,"svg"),l=document.createElementNS(a,"foreignObject"),u=document.createElementNS(o,"div"),c=document.createElementNS(o,"style");l.setAttribute("width","10000"),l.setAttribute("height","10000"),l.style.overflow="hidden",h.appendChild(l),this.maxWidth=hs.defaultMaxWidth,this.maxHeight=hs.defaultMaxHeight,this._domElement=u,this._styleElement=c,this._svgRoot=h,this._foreignObject=l,this._foreignObject.appendChild(c),this._foreignObject.appendChild(u),this._image=r,this._loadImage=new Image,this._autoResolution=hs.defaultAutoResolution,this._resolution=(s=hs.defaultResolution)!=null?s:N.RESOLUTION,this.text=t,this.style=e}measureText(t){var e,s;const{text:r,style:n,resolution:a}=Object.assign({text:this._text,style:this._style,resolution:this._resolution},t);Object.assign(this._domElement,{innerHTML:r,style:n.toCSS(a)}),this._styleElement.textContent=n.toGlobalCSS(),document.body.appendChild(this._svgRoot);const o=this._domElement.getBoundingClientRect();this._svgRoot.remove();const{width:h,height:l}=o,u=Math.min(this.maxWidth,Math.ceil(h)),c=Math.min(this.maxHeight,Math.ceil(l));return this._svgRoot.setAttribute("width",u.toString()),this._svgRoot.setAttribute("height",c.toString()),r!==this._text&&(this._domElement.innerHTML=this._text),n!==this._style&&(Object.assign(this._domElement,{style:(e=this._style)==null?void 0:e.toCSS(a)}),this._styleElement.textContent=(s=this._style)==null?void 0:s.toGlobalCSS()),{width:u+n.padding*2,height:c+n.padding*2}}async updateText(t=!0){const{style:e,_image:s,_loadImage:r}=this;if(this.localStyleID!==e.styleID&&(this.dirty=!0,this.localStyleID=e.styleID),!this.dirty&&t)return;const{width:n,height:a}=this.measureText();s.width=r.width=Math.ceil(Math.max(1,n)),s.height=r.height=Math.ceil(Math.max(1,a)),this._updateID++;const o=this._updateID;await new Promise(h=>{r.onload=async()=>{if(o/gi,"

").replace(/
/gi,"
").replace(/ /gi," ")}};ti.defaultDestroyOptions={texture:!0,children:!1,baseTexture:!0},ti.defaultMaxWidth=2024,ti.defaultMaxHeight=2024,ti.defaultAutoResolution=!0;let hg=ti;const Pe=new z;class ga{constructor(t){this.renderer=t}async image(t,e,s,r){const n=new Image;return n.src=await this.base64(t,e,s,r),n}async base64(t,e,s,r){const n=this.canvas(t,r);if(n.toBlob!==void 0)return new Promise((a,o)=>{n.toBlob(h=>{if(!h){o(new Error("ICanvas.toBlob failed!"));return}const l=new FileReader;l.onload=()=>a(l.result),l.onerror=o,l.readAsDataURL(h)},e,s)});if(n.toDataURL!==void 0)return n.toDataURL(e,s);if(n.convertToBlob!==void 0){const a=await n.convertToBlob({type:e,quality:s});return new Promise((o,h)=>{const l=new FileReader;l.onload=()=>o(l.result),l.onerror=h,l.readAsDataURL(a)})}throw new Error("CanvasExtract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(t,e){const s=this.renderer;if(!s)throw new Error("The CanvasExtract has already been destroyed");let r,n,a;t&&(t instanceof Yt?a=t:(a=s.generateTexture(t,{region:e,resolution:s.resolution}),e&&(Pe.width=e.width,Pe.height=e.height,e=Pe))),a?(r=a.baseTexture._canvasRenderTarget.context,n=a.baseTexture._canvasRenderTarget.resolution,e=e!=null?e:a.frame):(r=s.canvasContext.rootContext,n=s._view.resolution,e||(e=Pe,e.width=s.width/n,e.height=s.height/n));const o=Math.round(e.x*n),h=Math.round(e.y*n),l=Math.max(Math.round(e.width*n),1),u=Math.max(Math.round(e.height*n),1),c=new ys(l,u,1),d=r.getImageData(o,h,l,u);return c.context.putImageData(d,0,0),c.canvas}pixels(t,e){const s=this.renderer;if(!s)throw new Error("The CanvasExtract has already been destroyed");let r,n,a;t&&(t instanceof Yt?a=t:(a=s.generateTexture(t,{region:e,resolution:s.resolution}),e&&(Pe.width=e.width,Pe.height=e.height,e=Pe))),a?(r=a.baseTexture._canvasRenderTarget.context,n=a.baseTexture._canvasRenderTarget.resolution,e=e!=null?e:a.frame):(r=s.canvasContext.rootContext,n=s.resolution,e||(e=Pe,e.width=s.width/n,e.height=s.height/n));const o=Math.round(e.x*n),h=Math.round(e.y*n),l=Math.max(Math.round(e.width*n),1),u=Math.max(Math.round(e.height*n),1);return r.getImageData(o,h,l,u).data}destroy(){this.renderer=null}}ga.extension={name:"extract",type:D.CanvasRendererSystem},U.add(ga);let _a;const ei=new tt;rs.prototype.generateCanvasTexture=function(i,t=1){const e=this.getLocalBounds(new z);e.width=Math.max(e.width,1/t),e.height=Math.max(e.height,1/t);const s=Yt.create({width:e.width,height:e.height,scaleMode:i,resolution:t});_a||(_a=new Bs),this.transform.updateLocalTransform(),this.transform.localTransform.copyTo(ei),ei.invert(),ei.tx-=e.x,ei.ty-=e.y,_a.render(this,{renderTexture:s,clear:!0,transform:ei});const r=L.from(s.baseTexture._canvasRenderTarget.canvas,{scaleMode:i});return r.baseTexture.setResolution(t),r},rs.prototype.cachedGraphicsData=[],rs.prototype._renderCanvas=function(i){this.isMask!==!0&&(this.finishPoly(),i.plugins.graphics.render(this))};class si{static offsetPolygon(t,e){const s=[],r=t.length;e=si.isPolygonClockwise(t)?e:-1*e;for(let n=0;n0}}class va{constructor(t){this._svgMatrix=null,this._tempMatrix=new tt,this.renderer=t}_calcCanvasStyle(t,e){let s;return t.texture&&t.texture.baseTexture!==L.WHITE.baseTexture?t.texture.valid?(s=gt.getTintedPattern(t.texture,e),this.setPatternTransform(s,t.matrix||tt.IDENTITY)):s="#808080":s=`#${`00000${(e|0).toString(16)}`.slice(-6)}`,s}render(t){const e=this.renderer,s=e.canvasContext.activeContext,r=t.worldAlpha,n=t.transform.worldTransform;e.canvasContext.setContextTransform(n),e.canvasContext.setBlendMode(t.blendMode);const a=t.geometry.graphicsData;let o,h;const l=Y.shared.setValue(t.tint).toArray();for(let u=0;u0){A=[],b=0,R=x[0],w=x[1];for(let S=2;S+2=0;I-=2)s.lineTo(x[I],x[I+1])}v[S].shape.closeStroke&&s.closePath(),A[S]=T*b<0}}f.visible&&(s.globalAlpha=f.alpha*r,s.fillStyle=o,s.fill()),p.visible&&this.paintPolygonStroke(_,p,h,v,A,r,s)}else if(c.type===it.RECT){const _=d;if(f.visible&&(s.globalAlpha=f.alpha*r,s.fillStyle=o,s.fillRect(_.x,_.y,_.width,_.height)),p.visible){const x=p.width*(.5-(1-p.alignment)),v=_.width+2*x,b=_.height+2*x;s.globalAlpha=p.alpha*r,s.strokeStyle=h,s.strokeRect(_.x-x,_.y-x,v,b)}}else if(c.type===it.CIRC){const _=d;if(s.beginPath(),s.arc(_.x,_.y,_.radius,0,2*Math.PI),s.closePath(),f.visible&&(s.globalAlpha=f.alpha*r,s.fillStyle=o,s.fill()),p.visible){if(p.alignment!==.5){const x=p.width*(.5-(1-p.alignment));s.beginPath(),s.arc(_.x,_.y,_.radius+x,0,2*Math.PI),s.closePath()}s.globalAlpha=p.alpha*r,s.strokeStyle=h,s.stroke()}}else if(c.type===it.ELIP){const _=d,x=p.alignment===1;if(x||this.paintEllipse(_,f,p,o,r,s),p.visible){if(p.alignment!==.5){const v=.5522848,b=p.width*(.5-(1-p.alignment)),T=(_.width+b)*2,R=(_.height+b)*2,w=_.x-T/2,A=_.y-R/2,S=T/2*v,I=R/2*v,H=w+T,B=A+R,E=w+T/2,P=A+R/2;s.beginPath(),s.moveTo(w,P),s.bezierCurveTo(w,P-I,E-S,A,E,A),s.bezierCurveTo(E+S,A,H,P-I,H,P),s.bezierCurveTo(H,P+I,E+S,B,E,B),s.bezierCurveTo(E-S,B,w,P+I,w,P),s.closePath()}s.globalAlpha=p.alpha*r,s.strokeStyle=h,s.stroke()}x&&this.paintEllipse(_,f,p,o,r,s)}else if(c.type===it.RREC){const _=d,x=p.alignment===1;if(x||this.paintRoundedRectangle(_,f,p,o,r,s),p.visible){if(p.alignment!==.5){const v=_.width,b=_.height,T=p.width*(.5-(1-p.alignment)),R=_.x-T,w=_.y-T,A=_.width+2*T,S=_.height+2*T,I=T*(p.alignment>=1?Math.min(A/v,S/b):Math.min(v/A,b/S));let H=_.radius+I;const B=Math.min(A,S)/2;H=H>B?B:H,s.beginPath(),s.moveTo(R,w+H),s.lineTo(R,w+S-H),s.quadraticCurveTo(R,w+S,R+H,w+S),s.lineTo(R+A-H,w+S),s.quadraticCurveTo(R+A,w+S,R+A,w+S-H),s.lineTo(R+A,w+H),s.quadraticCurveTo(R+A,w,R+A-H,w),s.lineTo(R+H,w),s.quadraticCurveTo(R,w,R,w+H),s.closePath()}s.globalAlpha=p.alpha*r,s.strokeStyle=h,s.stroke()}x&&this.paintRoundedRectangle(_,f,p,o,r,s)}}}paintPolygonStroke(t,e,s,r,n,a,o){if(e.alignment!==.5){const h=e.width*(.5-(1-e.alignment));let l=si.offsetPolygon(t.points,h),u;o.beginPath(),o.moveTo(l[0],l[1]);for(let c=2;c=0;d-=2)o.lineTo(l[d],l[d+1])}r[c].shape.closeStroke&&o.closePath()}}o.globalAlpha=e.alpha*a,o.strokeStyle=s,o.stroke()}paintEllipse(t,e,s,r,n,a){const o=t.width*2,h=t.height*2,l=t.x-o/2,u=t.y-h/2,c=.5522848,d=o/2*c,f=h/2*c,p=l+o,m=u+h,g=l+o/2,_=u+h/2;s.alignment===0&&a.save(),a.beginPath(),a.moveTo(l,_),a.bezierCurveTo(l,_-f,g-d,u,g,u),a.bezierCurveTo(g+d,u,p,_-f,p,_),a.bezierCurveTo(p,_+f,g+d,m,g,m),a.bezierCurveTo(g-d,m,l,_+f,l,_),a.closePath(),s.alignment===0&&a.clip(),e.visible&&(a.globalAlpha=e.alpha*n,a.fillStyle=r,a.fill()),s.alignment===0&&a.restore()}paintRoundedRectangle(t,e,s,r,n,a){const o=t.x,h=t.y,l=t.width,u=t.height;let c=t.radius;const d=Math.min(l,u)/2;c=c>d?d:c,s.alignment===0&&a.save(),a.beginPath(),a.moveTo(o,h+c),a.lineTo(o,h+u-c),a.quadraticCurveTo(o,h+u,o+c,h+u),a.lineTo(o+l-c,h+u),a.quadraticCurveTo(o+l,h+u,o+l,h+u-c),a.lineTo(o+l,h+c),a.quadraticCurveTo(o+l,h,o+l-c,h),a.lineTo(o+c,h),a.quadraticCurveTo(o,h,o,h+c),a.closePath(),s.alignment===0&&a.clip(),e.visible&&(a.globalAlpha=e.alpha*n,a.fillStyle=r,a.fill()),s.alignment===0&&a.restore()}setPatternTransform(t,e){if(this._svgMatrix!==!1){if(!this._svgMatrix){const s=document.createElementNS("http://www.w3.org/2000/svg","svg");if(s!=null&&s.createSVGMatrix&&(this._svgMatrix=s.createSVGMatrix()),!this._svgMatrix||!t.setTransform){this._svgMatrix=!1;return}}this._svgMatrix.a=e.a,this._svgMatrix.b=e.b,this._svgMatrix.c=e.c,this._svgMatrix.d=e.d,this._svgMatrix.e=e.tx,this._svgMatrix.f=e.ty,t.setTransform(this._svgMatrix.inverse())}}destroy(){this.renderer=null,this._svgMatrix=null,this._tempMatrix=null}}va.extension={name:"graphics",type:D.CanvasRendererPlugin},U.add(va),Object.defineProperties(N,{MESH_CANVAS_PADDING:{get(){return Et.defaultCanvasPadding},set(i){Et.defaultCanvasPadding=i}}}),Xe.prototype._renderCanvas=function(i,t){i.plugins.mesh.render(t)},Ks.prototype._cachedTint=16777215,Ks.prototype._tintedCanvas=null,Ks.prototype._canvasUvs=null,Ks.prototype._renderCanvas=function(i){const t=i.canvasContext.activeContext,e=this.worldTransform,s=this.tintValue!==16777215,r=this.texture;if(!r.valid)return;s&&this._cachedTint!==this.tintValue&&(this._cachedTint=this.tintValue,this._tintedCanvas=gt.getTintedCanvas(this,this.tintValue));const n=s?this._tintedCanvas:r.baseTexture.getDrawableSource();this._canvasUvs||(this._canvasUvs=[0,0,0,0,0,0,0,0]);const a=this.vertices,o=this._canvasUvs,h=s?0:r.frame.x,l=s?0:r.frame.y,u=h+r.frame.width,c=l+r.frame.height;o[0]=h,o[1]=h+this._leftWidth,o[2]=u-this._rightWidth,o[3]=u,o[4]=l,o[5]=l+this._topHeight,o[6]=c-this._bottomHeight,o[7]=c;for(let d=0;d<8;d++)o[d]*=r.baseTexture.resolution;t.globalAlpha=this.worldAlpha,i.canvasContext.setBlendMode(this.blendMode),i.canvasContext.setContextTransform(e,this.roundPixels);for(let d=0;d<3;d++)for(let f=0;f<3;f++){const p=f*2+d*8,m=Math.max(1,o[f+1]-o[f]),g=Math.max(1,o[d+5]-o[d+4]),_=Math.max(1,a[p+10]-a[p]),x=Math.max(1,a[p+11]-a[p+1]);t.drawImage(n,o[f],o[d+4],m,g,a[p],a[p+1],_,x)}};let Fu=!1;Et.prototype._cachedTint=16777215,Et.prototype._tintedCanvas=null,Et.prototype._cachedTexture=null,Et.prototype._renderCanvas=function(i){this.shader.uvMatrix&&(this.shader.uvMatrix.update(),this.calculateUvs()),this.material._renderCanvas?this.material._renderCanvas(i,this):Fu||(Fu=!0,globalThis.console.warn("Mesh with custom shaders are not supported in CanvasRenderer."))},Et.prototype._canvasPadding=null,Et.defaultCanvasPadding=0,Object.defineProperty(Et.prototype,"canvasPadding",{get(){var i;return(i=this._canvasPadding)!=null?i:Et.defaultCanvasPadding},set(i){this._canvasPadding=i}}),mu.prototype._renderCanvas=function(i){this.autoUpdate&&this.geometry.getBuffer("aVertexPosition").update(),this.shader.update&&this.shader.update(),this.calculateUvs(),this.material._renderCanvas(i,this)},gu.prototype._renderCanvas=function(i){(this.autoUpdate||this.geometry._width!==this.shader.texture.height)&&(this.geometry._width=this.shader.texture.height,this.geometry.update()),this.shader.update&&this.shader.update(),this.calculateUvs(),this.material._renderCanvas(i,this)};class ya{constructor(t){this.renderer=t}render(t){const e=this.renderer,s=t.worldTransform;e.canvasContext.activeContext.globalAlpha=t.worldAlpha,e.canvasContext.setBlendMode(t.blendMode),e.canvasContext.setContextTransform(s,t.roundPixels),t.drawMode!==Ot.TRIANGLES?this._renderTriangleMesh(t):this._renderTriangles(t)}_renderTriangleMesh(t){const e=t.geometry.buffers[0].data.length;for(let s=0;s0){const{a:ht,b:F,c:O,d:Z}=t.worldTransform,Q=(T+R+w)/3,J=(A+S+I)/3;let st=T-Q,et=A-J,rt=ht*st+O*et,lt=F*st+Z*et,_t=Math.sqrt(rt*rt+lt*lt),nt=1+H/_t;T=Q+st*nt,A=J+et*nt,st=R-Q,et=S-J,rt=ht*st+O*et,lt=F*st+Z*et,_t=Math.sqrt(rt*rt+lt*lt),nt=1+H/_t,R=Q+st*nt,S=J+et*nt,st=w-Q,et=I-J,rt=ht*st+O*et,lt=F*st+Z*et,_t=Math.sqrt(rt*rt+lt*lt),nt=1+H/_t,w=Q+st*nt,I=J+et*nt}a.save(),a.beginPath(),a.moveTo(T,A),a.lineTo(R,S),a.lineTo(w,I),a.closePath(),a.clip();const B=m*v+x*_+g*b-v*_-x*g-m*b,E=T*v+x*w+R*b-v*w-x*R-T*b,P=m*R+T*_+g*w-R*_-T*g-m*w,V=m*v*w+x*R*_+T*g*b-T*v*_-x*g*w-m*R*b,q=A*v+x*I+S*b-v*I-x*S-A*b,j=m*S+A*_+g*I-S*_-A*g-m*I,W=m*v*I+x*S*_+A*g*b-A*v*_-x*g*I-m*S*b;a.transform(E/B,q/B,P/B,j/B,V/B,W/B),a.drawImage(p,0,0,d*c.resolution,f*c.resolution,0,0,d,f),a.restore(),this.renderer.canvasContext.invalidateBlendMode()}renderMeshFlat(t){const e=this.renderer.canvasContext.activeContext,s=t.geometry.getBuffer("aVertexPosition").data,r=s.length/2;e.beginPath();for(let n=1;n{if(typeof require=="function"){const e=this._game.getAdditionalOptions(),t=e&&e.electronRemoteRequirePath?e.electronRemoteRequirePath:"@electron/remote";try{return require(t)}catch(i){console.error(`Could not load @electron/remote from "${t}". Error is:`,i)}}return null};this._game=e,this._forceFullscreen=t,this._marginLeft=this._marginTop=this._marginRight=this._marginBottom=0,this._setupOrientation()}createStandardCanvas(e){this._throwIfDisposed();const t=document.createElement("canvas");e.appendChild(t),this.initializeRenderers(t),this.initializeCanvas(t)}initializeRenderers(e){this._throwIfDisposed(),typeof THREE!="undefined"?(this._threeRenderer=new THREE.WebGLRenderer({canvas:e,antialias:this._game.getAntialiasingMode()!=="none"&&(this._game.isAntialisingEnabledOnMobile()||!l.evtTools.common.isMobile()),preserveDrawingBuffer:!0}),this._threeRenderer.useLegacyLights=!0,this._threeRenderer.autoClear=!1,this._threeRenderer.setSize(this._game.getGameResolutionWidth(),this._game.getGameResolutionHeight()),this._pixiRenderer=new PIXI.Renderer({width:this._game.getGameResolutionWidth(),height:this._game.getGameResolutionHeight(),view:e,context:this._threeRenderer.getContext(),clearBeforeRender:!1,preserveDrawingBuffer:!0,antialias:!1,backgroundAlpha:0})):this._pixiRenderer=PIXI.autoDetectRenderer({width:this._game.getGameResolutionWidth(),height:this._game.getGameResolutionHeight(),view:e,preserveDrawingBuffer:!0,antialias:!1}),this._pixiRenderer.plugins.accessibility.destroy(),delete this._pixiRenderer.plugins.accessibility}initializeCanvas(e){this._gameCanvas=e,e.style.position="absolute",e.tabIndex=1,e.style.userSelect="none",e.style.outline="none";const t=document.createElement("div");t.style.position="absolute",t.style.overflow="hidden",t.style.outline="none",t.style.pointerEvents="none",t.addEventListener("scroll",i=>{t.scrollLeft=0,t.scrollTop=0,i.preventDefault()}),e.addEventListener("pointerdown",()=>{e.focus()}),t.style["-webkit-user-select"]="none",e.parentNode?.appendChild(t),this._domElementsContainer=t,this._resizeCanvas(),this._game.getScaleMode()==="nearest"&&(e.style["image-rendering"]="-moz-crisp-edges",e.style["image-rendering"]="-webkit-optimize-contrast",e.style["image-rendering"]="-webkit-crisp-edges",e.style["image-rendering"]="pixelated"),this._game.getPixelsRounding()&&(PIXI.settings.ROUND_PIXELS=!0),window.addEventListener("resize",()=>{this._game.onWindowInnerSizeChanged(),this._resizeCanvas()}),e.focus()}static getWindowInnerWidth(){return typeof window!="undefined"?window.innerWidth:800}static getWindowInnerHeight(){return typeof window!="undefined"?window.innerHeight:800}updateRendererSize(){this._resizeCanvas()}_setupOrientation(){if(typeof window=="undefined"||!window.screen||!window.screen.orientation)return;const e=this._game.getGameData().properties.orientation;try{if(e==="default"){const t=window.screen.orientation.unlock();t&&t.catch(()=>{})}else window.screen.orientation.lock(e).catch(()=>{})}catch(t){u.error("Unexpected error while setting up orientation: ",t)}}_resizeCanvas(){if(!this._pixiRenderer||!this._domElementsContainer)return;(this._pixiRenderer.width!==this._game.getGameResolutionWidth()||this._pixiRenderer.height!==this._game.getGameResolutionHeight())&&(this._pixiRenderer.resize(this._game.getGameResolutionWidth(),this._game.getGameResolutionHeight()),this._threeRenderer&&this._threeRenderer.setSize(this._game.getGameResolutionWidth(),this._game.getGameResolutionHeight()));const e=this._forceFullscreen||this._isFullPage||this._isFullscreen;let t=this._game.getGameResolutionWidth(),i=this._game.getGameResolutionHeight(),o=window.innerWidth-this._marginLeft-this._marginRight,r=window.innerHeight-this._marginTop-this._marginBottom;if(o<0&&(o=0),r<0&&(r=0),e&&!this._keepRatio)t=o,i=r;else if(e&&this._keepRatio||t>o||i>r){let d=o/t;i*d>r&&(d=r/i),t*=d,i*=d}this._gameCanvas&&(this._gameCanvas.style.top=this._marginTop+(r-i)/2+"px",this._gameCanvas.style.left=this._marginLeft+(o-t)/2+"px",this._gameCanvas.style.width=t+"px",this._gameCanvas.style.height=i+"px"),this._domElementsContainer.style.top=this._marginTop+(r-i)/2+"px",this._domElementsContainer.style.left=this._marginLeft+(o-t)/2+"px",this._domElementsContainer.style.width=t+"px",this._domElementsContainer.style.height=i+"px",this._canvasWidth=t,this._canvasHeight=i}keepAspectRatio(e){this._keepRatio!==e&&(this._keepRatio=e,this._resizeCanvas())}setMargins(e,t,i,o){this._throwIfDisposed(),!(this._marginTop===e&&this._marginRight===t&&this._marginBottom===i&&this._marginLeft===o)&&(this._marginTop=e,this._marginRight=t,this._marginBottom=i,this._marginLeft=o,this._resizeCanvas())}setWindowSize(e,t){this._throwIfDisposed();const i=this.getElectronRemote();if(i){const o=i.getCurrentWindow();try{o&&o.setContentSize(e,t)}catch(r){u.error(`Window size setting to width ${e} and height ${t} failed. See error:`,r)}}else u.warn("Window size can't be changed on this platform.")}centerWindow(){this._throwIfDisposed();const e=this.getElectronRemote();if(e){const t=e.getCurrentWindow();try{t&&t.center()}catch(i){u.error("Window centering failed. See error:",i)}}else u.warn("Window can't be centered on this platform.")}setFullScreen(e){if(this._throwIfDisposed(),!this._forceFullscreen&&this._isFullscreen!==e){this._isFullscreen=!!e;const t=this.getElectronRemote();if(t){const i=t.getCurrentWindow();try{i&&i.setFullScreen(this._isFullscreen)}catch(o){u.error(`Full screen setting to ${this._isFullscreen} failed. See error:`,o)}}else this._isFullscreen?document.documentElement.requestFullscreen?document.documentElement.requestFullscreen():document.documentElement.mozRequestFullScreen?document.documentElement.mozRequestFullScreen():document.documentElement.webkitRequestFullScreen&&document.documentElement.webkitRequestFullScreen():document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitCancelFullScreen&&document.webkitCancelFullScreen();this._resizeCanvas()}}isFullScreen(){const e=this.getElectronRemote();if(e)try{return e.getCurrentWindow().isFullScreen()}catch(t){return u.error("Full screen detection failed. See error:",t),!1}return this._isFullscreen||window.screen.height===window.innerHeight}convertCanvasToDomElementContainerCoords(e,t){const i=t||[0,0];return i[0]=e[0]*this._canvasWidth/this._game.getGameResolutionWidth(),i[1]=e[1]*this._canvasHeight/this._game.getGameResolutionHeight(),i}getCanvasToDomElementContainerHeightScale(){return(this._canvasHeight||1)/this._game.getGameResolutionHeight()}bindStandardEvents(e,t,i){this._throwIfDisposed();const o=this._gameCanvas;if(!o)return;const r=n=>{const s=[n.pageX-o.offsetLeft,n.pageY-o.offsetTop];return s[0]*=this._game.getGameResolutionWidth()/(this._canvasWidth||1),s[1]*=this._game.getGameResolutionHeight()/(this._canvasHeight||1),s},d=n=>{const s=n.pageX-o.offsetLeft,a=n.pageY-o.offsetTop;return 0<=s&&s<(this._canvasWidth||1)&&0<=a&&a<(this._canvasHeight||1)};(function(){isNaN(o.offsetLeft)&&(o.offsetLeft=0,o.offsetTop=0),isNaN(i.body.scrollLeft)&&(i.body.scrollLeft=0,i.body.scrollTop=0),(i.documentElement===void 0||i.documentElement===null)&&(i.documentElement={}),isNaN(i.documentElement.scrollLeft)&&(i.documentElement.scrollLeft=0,i.documentElement.scrollTop=0),isNaN(o.offsetLeft)&&(o.offsetLeft=0,o.offsetTop=0)})();const m=()=>!(i.activeElement===o||i.activeElement===i.body||i.activeElement===null),h=n=>!(n.target===o||n.target===i.body);i.onkeydown=function(n){m()||(f.includes(n.keyCode)&&n.preventDefault(),e.onKeyPressed(n.keyCode,n.location))},i.onkeyup=function(n){m()||(f.includes(n.keyCode)&&n.preventDefault(),e.onKeyReleased(n.keyCode,n.location))};function g(n){switch(n){case 1:return l.InputManager.MOUSE_MIDDLE_BUTTON;case 2:return l.InputManager.MOUSE_RIGHT_BUTTON}return n}o.onmousemove=function(n){const s=r(n);e.onMouseMove(s[0],s[1])},o.onmousedown=function(n){return e.onMouseButtonPressed(g(n.button)),t.focus!==void 0&&t.focus(),!1},o.onmouseup=function(n){return e.onMouseButtonReleased(g(n.button)),!1},o.onmouseleave=function(n){e.onMouseLeave()},o.onmouseenter=function(n){e.onMouseEnter();const s=[l.InputManager.MOUSE_LEFT_BUTTON,l.InputManager.MOUSE_RIGHT_BUTTON,l.InputManager.MOUSE_MIDDLE_BUTTON,l.InputManager.MOUSE_BACK_BUTTON,l.InputManager.MOUSE_FORWARD_BUTTON];for(let a=0,v=s.length;a{this._nextFrameId=requestAnimationFrame(i);const r=t?o-t:0;t=o,e(r)||cancelAnimationFrame(this._nextFrameId)};requestAnimationFrame(i)}stopGameLoop(){cancelAnimationFrame(this._nextFrameId)}getPIXIRenderer(){return this._pixiRenderer}getThreeRenderer(){return this._threeRenderer}getDomElementContainer(){return this._domElementsContainer}openURL(e){if(typeof window!="undefined"){const t=this.getElectron();t?t.shell.openExternal(e):typeof window.cordova!="undefined"&&typeof window.cordova.InAppBrowser!="undefined"?window.cordova.InAppBrowser.open(e,"_system","location=yes"):window.open(e,"_blank")}}stopGame(){const e=this.getElectronRemote();if(e){const t=e.getCurrentWindow();if(t)try{t.close()}catch(i){u.error("Window closing failed. See error:",i)}}else typeof navigator!="undefined"&&navigator.app&&navigator.app.exitApp&&navigator.app.exitApp()}dispose(e){this._pixiRenderer?.destroy(),this._threeRenderer?.dispose(),this._pixiRenderer=null,this._threeRenderer=null,e&&this._gameCanvas&&this._gameCanvas.parentNode?.removeChild(this._gameCanvas),this._gameCanvas=null,this._domElementsContainer?.parentNode?.removeChild(this._domElementsContainer),this._domElementsContainer=null,this._wasDisposed=!0}getCanvas(){return this._gameCanvas}isWebGLSupported(){return!!this._pixiRenderer&&this._pixiRenderer.type===PIXI.RENDERER_TYPE.WEBGL}getElectron(){return typeof require=="function"?require("electron"):null}getGame(){return this._game}_throwIfDisposed(){if(this._wasDisposed)throw"The RuntimeGameRenderer has been disposed and should not be used anymore."}}l.RuntimeGamePixiRenderer=R,l.RuntimeGameRenderer=R})(gdjs||(gdjs={})); +//# sourceMappingURL=runtimegame-pixi-renderer.js.map diff --git a/pixi-renderers/runtimescene-pixi-renderer.js b/pixi-renderers/runtimescene-pixi-renderer.js new file mode 100644 index 0000000000000000000000000000000000000000..c70fffd975a026b990712e436e9bf155e99ca1b1 --- /dev/null +++ b/pixi-renderers/runtimescene-pixi-renderer.js @@ -0,0 +1,3 @@ +var gdjs;(function(o){class _{constructor(t,e){this._profilerText=null;this._showCursorAtNextRender=!1;this._threeRenderer=null;this._layerRenderingMetrics={rendered2DLayersCount:0,rendered3DLayersCount:0};this._runtimeGameRenderer=e,this._runtimeScene=t,this._pixiContainer=new PIXI.Container,this._pixiContainer.sortableChildren=!0,this._threeRenderer=this._runtimeGameRenderer?this._runtimeGameRenderer.getThreeRenderer():null}onGameResolutionResized(){const t=this._runtimeGameRenderer?this._runtimeGameRenderer.getPIXIRenderer():null;if(!t)return;const e=this._runtimeScene.getGame();this._pixiContainer.scale.x=t.width/e.getGameResolutionWidth(),this._pixiContainer.scale.y=t.height/e.getGameResolutionHeight();for(const r of this._runtimeScene._orderedLayers)r.getRenderer().onGameResolutionResized()}onSceneUnloaded(){}render(){const t=this._runtimeGameRenderer;if(!t)return;const e=t.getPIXIRenderer();if(!e)return;const r=this._threeRenderer;if(!(r&&r.xr.isPresenting)){if(this._layerRenderingMetrics.rendered2DLayersCount=0,this._layerRenderingMetrics.rendered3DLayersCount=0,r){r.info.autoReset=!1,r.info.reset();let n=!0,s=!0;r.resetState();for(let c=0;c({collision:!1,move_axis:[0,0]}),S=()=>({collision:!1,closeX:0,closeY:0,closeSqDist:0,farX:0,farY:0,farSqDist:0,edgeX:0,edgeY:0}),F={minMaxA:[0,0],minMaxB:[0,0],edge:[0,0],axis:[0,0],move_axis:[0,0],result:D()},R={p:[0,0],q:[0,0],r:[0,0],s:[0,0],deltaQP:[0,0],axis:[0,0],result:S()},c=class{constructor(){this.vertices=[];this.edges=[];this.center=[0,0]}move(t,e){for(let o=0,i=this.vertices.length;o=e?this.vertices[0]:this.vertices[t+1];this.edges[t][0]=i[0]-o[0],this.edges[t][1]=i[1]-o[1]}}isConvex(){this.computeEdges();const t=this.edges.length;if(t<3)return!1;const e=this.edges[0][0]*this.edges[0+1][1]-this.edges[0][1]*this.edges[0+1][0]>0;for(let i=1;i0!==e)return!1;return this.edges[t-1][0]*this.edges[0][1]-this.edges[t-1][1]*this.edges[0][0]>0===e}computeCenter(){this.center[0]=0,this.center[1]=0;const t=this.vertices.length;for(let e=0;e0||r===0&&o)return s.collision=!1,s.move_axis[0]=0,s.move_axis[1]=0,s;const h=Math.abs(r);hy)return s;if(s.collision=!0,u===0)return s.closeX=e,s.closeY=o,s.closeSqDist=0,s.farX=e,s.farY=o,s.farSqDist=0,s.edgeX=f[0],s.edgeY=f[1],s;const q=Y/Math.abs(u),T=y/Math.abs(u);return s.closeX=e+q*a[0],s.closeY=o+q*a[1],s.closeSqDist=q*q*(a[0]*a[0]+a[1]*a[1]),s.farX=e+T*a[0],s.farY=o+T*a[1],s.farSqDist=T*T*(a[0]*a[0]+a[1]*a[1]),s.edgeX=f[0],s.edgeY=f[1],s}else if(d!==0&&0<=x&&x<=1&&0<=M&&M<=1){const r=n[0]+x*a[0],h=n[1]+x*a[1],u=(r-e)*(r-e)+(h-o)*(h-o);uo[1]&&(o[1]=i)}static distance(t,e,o,i){return to!=g[1]>o&&e<(g[0]-n[0])*(o-n[1])/(g[1]-n[1])+n[0]&&(i=!i)}return i}static copyCollisionTestResult(t,e){e.collision=t.collision,e.move_axis[0]=t.move_axis[0],e.move_axis[1]=t.move_axis[1]}static copyRaycastTestResult(t,e){e.collision=t.collision,e.closeX=t.closeX,e.closeY=t.closeY,e.closeSqDist=t.closeSqDist,e.farX=t.farX,e.farY=t.farY,e.farSqDist=t.farSqDist,e.edgeX=t.edgeX,e.edgeY=t.edgeY}};let C=c;C.makeNewCollisionTestResult=D,C.makeNewRaycastTestResult=S,b.Polygon=C})(gdjs||(gdjs={})); +//# sourceMappingURL=polygon.js.map diff --git a/profiler.js b/profiler.js new file mode 100644 index 0000000000000000000000000000000000000000..c1705322a353283c0ebbc94f390d5dcb8c681d47 --- /dev/null +++ b/profiler.js @@ -0,0 +1,2 @@ +var gdjs;(function(m){class a{constructor(){this._framesMeasures=[];this._currentFrameIndex=0;this._currentFrameMeasure={parent:null,time:0,lastStartTime:0,subsections:{}};this._currentSection=null;this._maxFramesCount=600;this._framesCount=0;for(;this._framesMeasures.lengththis._maxFramesCount&&(this._framesCount=this._maxFramesCount),this._framesMeasures[this._currentFrameIndex]=this._currentFrameMeasure,this._currentFrameIndex++,this._currentFrameIndex>=this._maxFramesCount&&(this._currentFrameIndex=0)}static _addAverageSectionTimes(t,e,r,o){e.time=(e.time||0)+t.time/r;for(const s in t.subsections)if(t.subsections.hasOwnProperty(s)){const n=e.subsections,i=n[s]=n[s]||{parent:e,time:0,subsections:{}};a._addAverageSectionTimes(t.subsections[s],i,r,o)}}getFramesAverageMeasures(){const t={parent:null,time:0,lastStartTime:0,subsections:{}};for(let e=0;enew Promise(e=>setTimeout(e,u)),h=u=>u.usedResources.map(e=>e.name);let l=null;const p=()=>{if(l)return l;l=[];try{new CompressionStream("gzip"),l.push("cs:gzip")}catch{}try{new CompressionStream("deflate"),l.push("cs:deflate")}catch{}return l};class _{constructor(e,t){this._sceneAndExtensionsData=[];this._notifyScenesForGameResolutionResize=!1;this._paused=!1;this._hasJustResumed=!1;this._sessionMetricsInitialized=!1;this._disableMetrics=!1;this._wasDisposed=!1;this.getPlatformInfo=()=>({isCordova:!!window.cordova,devicePlatform:typeof device!="undefined"&&device.platform||"",navigatorPlatform:typeof navigator!="undefined"?navigator.platform:"",hasTouch:typeof navigator!="undefined"?!!navigator.maxTouchPoints&&navigator.maxTouchPoints>2:!1,supportedCompressionMethods:p()});this._options=t||{},this._variables=new n.VariablesContainer(e.variables),this._variablesByExtensionName=new Map;for(const s of e.eventsFunctionsExtensions)s.globalVariables.length>0&&this._variablesByExtensionName.set(s.name,new n.VariablesContainer(s.globalVariables));this._eventsBasedObjectDatas=new Map,this._data=e,this._updateSceneAndExtensionsData(),this._resourcesLoader=new n.ResourceLoader(this,e.resources.resources,h(e),e.layouts),this._effectsManager=new n.EffectsManager,this._maxFPS=this._data.properties.maxFPS,this._minFPS=this._data.properties.minFPS,this._gameResolutionWidth=this._data.properties.windowWidth,this._gameResolutionHeight=this._data.properties.windowHeight,this._originalWidth=this._gameResolutionWidth,this._originalHeight=this._gameResolutionHeight,this._resizeMode=this._data.properties.sizeOnStartupMode,this._adaptGameResolutionAtRuntime=this._data.properties.adaptGameResolutionAtRuntime,this._scaleMode=e.properties.scaleMode||"linear",this._pixelsRounding=this._data.properties.pixelsRounding,this._antialiasingMode=this._data.properties.antialiasingMode,this._isAntialisingEnabledOnMobile=this._data.properties.antialisingEnabledOnMobile,this._renderer=new n.RuntimeGameRenderer(this,this._options.forceFullscreen||!1),this._watermark=new n.watermark.RuntimeWatermark(this,e.properties.authorUsernames,this._data.properties.watermark),this._sceneStack=new n.SceneStack(this),this._inputManager=new n.InputManager,this._injectExternalLayout=this._options.injectExternalLayout||"",this._debuggerClient=n.DebuggerClient?new n.DebuggerClient(this):null,this._captureManager=n.CaptureManager?new n.CaptureManager(this._renderer,this._options.captureOptions||{}):null,this._isPreview=this._options.isPreview||!1,this._sessionId=null,this._playerId=null,this._embeddedResourcesMappings=new Map;for(const s of this._data.resources.resources)if(s.metadata)try{const i=JSON.parse(s.metadata);i?.embeddedResourcesMapping&&this._embeddedResourcesMappings.set(s.name,i.embeddedResourcesMapping)}catch{g.error("Some metadata of resources can not be successfully parsed.")}this.isUsingGDevelopDevelopmentEnvironment()&&g.info("This game will run on the development version of GDevelop APIs.")}setProjectData(e){this._data=e,this._updateSceneAndExtensionsData(),this._resourcesLoader.setResources(e.resources.resources,h(e),e.layouts)}_updateSceneAndExtensionsData(){const e=this._data.eventsFunctionsExtensions.filter(t=>t.sceneVariables.length>0);if(this._sceneAndExtensionsData=this._data.layouts.map(t=>({sceneData:t,usedExtensionsWithVariablesData:e})),this._eventsBasedObjectDatas.clear(),this._data.eventsFunctionsExtensions)for(const t of this._data.eventsFunctionsExtensions)for(const s of t.eventsBasedObjects)this._eventsBasedObjectDatas.set(t.name+"::"+s.name,s)}getAdditionalOptions(){return this._options}getRenderer(){return this._renderer}getVariables(){return this._variables}getVariablesForExtension(e){return this._variablesByExtensionName.get(e)||null}getSoundManager(){return this._resourcesLoader.getSoundManager()}getImageManager(){return this._resourcesLoader.getImageManager()}getFontManager(){return this._resourcesLoader.getFontManager()}getBitmapFontManager(){return this._resourcesLoader.getBitmapFontManager()}getJsonManager(){return this._resourcesLoader.getJsonManager()}getModel3DManager(){return this._resourcesLoader.getModel3DManager()}getSpineManager(){return this._resourcesLoader.getSpineManager()}getSpineAtlasManager(){return this._resourcesLoader.getSpineAtlasManager()}getInputManager(){return this._inputManager}getEffectsManager(){return this._effectsManager}getGameData(){return this._data}getEventsBasedObjectData(e){const t=this._eventsBasedObjectDatas.get(e);return t||(g.error('The game has no events-based object of the type "'+e+'"'),null)}getSceneAndExtensionsData(e){for(let t=0,s=this._sceneAndExtensionsData.length;t{await this._resourcesLoader.loadGlobalAndFirstSceneResources(e,i),this._resourcesLoader.loadAllSceneInBackground()},t),n.getAllAsynchronouslyLoadingLibraryPromise()])}catch(s){throw this._debuggerClient&&this._debuggerClient.onUncaughtException(s),s}}async loadSceneAssets(e,t){await this._loadAssetsWithLoadingScreen(!1,async s=>{await this._resourcesLoader.loadAndProcessSceneResources(e,s)},t)}async _loadAssetsWithLoadingScreen(e,t,s){this.pause(!0);const i=new n.LoadingScreenRenderer(this.getRenderer(),this._resourcesLoader.getImageManager(),this._data.properties.loadingScreen,this._data.properties.watermark.showWatermark,e);await t(async(o,a)=>{const d=Math.floor(100*o/a);i.setPercent(d),s&&s(d),i.renderIfNeeded()&&await c(1)}),await i.unload(),this.pause(!1)}_getFirstSceneName(){const e=this._data.firstLayout;return this.hasScene(e)?e:this.getSceneAndExtensionsData().sceneData.name}startGameLoop(){this._throwIfDisposed();try{if(!this.hasScene()){g.error("The game has no scene.");return}this._forceGameResolutionUpdate(),this._sceneStack.push(this._getFirstSceneName(),this._injectExternalLayout),this._watermark.displayAtStartup(),this._setupGameVisibilityEvents();let e=0;this._hasJustResumed=!1,this._renderer.startGameLoop(t=>{try{if(this._paused||(e+=t,this._maxFPS>0&&1e3/e>this._maxFPS+7))return!0;const s=e;return e=0,this._notifyScenesForGameResolutionResize&&(this._sceneStack.onGameResolutionResized(),this._notifyScenesForGameResolutionResize=!1),this._sceneStack.step(s)?(this.getInputManager().onFrameEnded(),this._hasJustResumed=!1,!0):!1}catch(s){throw this._debuggerClient&&this._debuggerClient.onUncaughtException(s),s}}),setTimeout(()=>{this._setupSessionMetrics()},4e3),this._captureManager&&this._captureManager.setupCaptureOptions(this._isPreview)}catch(e){throw this._debuggerClient&&this._debuggerClient.onUncaughtException(e),e}}dispose(e){this._renderer.stopGameLoop(),this._sceneStack.dispose(),this._renderer.dispose(e),this._resourcesLoader.dispose(),this._wasDisposed=!0}enableMetrics(e){this._disableMetrics=!e,e&&this._setupSessionMetrics()}_setupGameVisibilityEvents(){typeof navigator!="undefined"&&typeof document!="undefined"&&(document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"&&(this._hasJustResumed=!0)}),window.addEventListener("resume",()=>{this._hasJustResumed=!0},!1))}_setupSessionMetrics(){if(this._sessionMetricsInitialized||this._disableMetrics||this.isPreview()||typeof fetch=="undefined"||!this._data.properties.projectUuid)return;const e="https://api.gdevelop-app.com/analytics";this._playerId=this._makePlayerUuid();let t=0,s=0,i=Date.now();const r=this.getPlatformInfo();fetch(e+"/session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gameId:this._data.properties.projectUuid,playerId:this._playerId,game:{name:this._data.properties.name||"",packageName:this._data.properties.packageName||"",version:this._data.properties.version||"",location:window.location.href},platform:{isCordova:r.isCordova,devicePlatform:r.devicePlatform,navigatorPlatform:r.navigatorPlatform,hasTouch:r.hasTouch}})}).then(a=>{if(!a.ok)throw console.error("Error while creating the session",a),new Error("Error while creating the session");return a}).then(a=>a.text()).then(a=>{this._sessionId=a}).catch(()=>{});const o=()=>{if(!this._sessionId)return;const a=Date.now();if(s+=a-i,i=a,s<5*1e3)return;const d=Math.floor(s/1e3)*1e3;t+=d,s-=d,navigator.sendBeacon(e+"/session-hit",JSON.stringify({gameId:this._data.properties.projectUuid,playerId:this._playerId,sessionId:this._sessionId,duration:Math.floor(t/1e3)}))};if(typeof navigator!="undefined"&&typeof document!="undefined"){document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?i=Date.now():o()}),window.addEventListener("pagehide",o,!1),window.addEventListener("pause",o,!1),window.addEventListener("resume",()=>{i=Date.now()},!1);const a=typeof safari=="object"&&safari.pushNotification,d=/electron/i.test(navigator.userAgent);(a||d)&&window.addEventListener("beforeunload",()=>{o()})}this._sessionMetricsInitialized=!0,this._sessionId=this._sessionId}_makePlayerUuid(){try{const e="GDJS-internal-player-uuid",t=localStorage.getItem(e);if(t)return t;const s=n.makeUuid();return localStorage.setItem(e,s),s}catch{return n.makeUuid()}}getSessionId(){return this._sessionId}getPlayerId(){return this._playerId}onWindowInnerSizeChanged(){this._forceGameResolutionUpdate()}_forceGameResolutionUpdate(){this.setGameResolutionSize(this._gameResolutionWidth,this._gameResolutionHeight)}startCurrentSceneProfiler(e){this._throwIfDisposed();const t=this._sceneStack.getCurrentScene();return t?(t.startProfiler(e),!0):!1}stopCurrentSceneProfiler(){this._throwIfDisposed();const e=this._sceneStack.getCurrentScene();!e||e.stopProfiler()}wasFirstSceneLoaded(){return this._sceneStack.wasFirstSceneLoaded()}getSceneStack(){return this._sceneStack}isPreview(){return this._isPreview}isUsingGDevelopDevelopmentEnvironment(){return this._options.environment==="dev"}getExtensionProperty(e,t){for(let s of this._data.properties.extensionProperties)if(s.extension===e&&s.property===t)return s.value;return null}resolveEmbeddedResource(e,t){const s=this._embeddedResourcesMappings.get(e);return s&&s[t]?s[t]:t}getEmbeddedResourcesNames(e){return this._embeddedResourcesMappings.has(e)?Object.keys(this._embeddedResourcesMappings.get(e)):[]}getNetworkSyncData(e){const t={var:this._variables.getNetworkSyncData(e),ss:this._sceneStack.getNetworkSyncData(e)||void 0},s={};return this._variablesByExtensionName.forEach((i,r)=>{const o=i.getNetworkSyncData(e);o.length&&(s[r]=o)}),t.extVar=s,(!t.var||t.var.length===0)&&!t.ss&&(!t.extVar||Object.keys(t.extVar).length===0)?null:t}updateFromNetworkSyncData(e){if(this._throwIfDisposed(),e.var&&this._variables.updateFromNetworkSyncData(e.var),e.ss&&this._sceneStack.updateFromNetworkSyncData(e.ss),e.extVar)for(const t in e.extVar){if(!e.extVar.hasOwnProperty(t))continue;const s=e.extVar[t],i=this.getVariablesForExtension(t);i&&i.updateFromNetworkSyncData(s)}}_throwIfDisposed(){if(this._wasDisposed)throw"The RuntimeGame has been disposed and should not be used anymore."}}n.RuntimeGame=_})(gdjs||(gdjs={})); +//# sourceMappingURL=runtimegame.js.map diff --git a/runtimeobject.js b/runtimeobject.js new file mode 100644 index 0000000000000000000000000000000000000000..873123de66071831831059fa9974fbf15c53c662 --- /dev/null +++ b/runtimeobject.js @@ -0,0 +1,2 @@ +var gdjs;(function(n){const _=(C,e,t,i)=>{const s=Math.max(t,C-t),r=Math.max(i,e-i);return Math.pow(s,2)+Math.pow(r,2)},x={moveXArray:[],moveYArray:[]},D={result:n.Polygon.makeNewRaycastTestResult()},F=(C,e,t)=>{if(e.length===0)return e.length=0,t.length=0,!1;if(e.length===1)return C.setPosition(C.getX()+e[0],C.getY()+t[0]),e.length=0,t.length=0,!0;let i=0,s=0;for(let f=0;fi&&(i=A,s=f)}const r=Math.sqrt(i),a=e[s]/r,h=-(t[s]/r),m=a;let g=0,c=0;for(let f=0;f{if(!r.isSyncedOverNetwork())return;const a=r.getNetworkSyncData();a&&(e[r.getName()]=a)});const t=this._variables.getNetworkSyncData({}),i={};for(const r in this._rendererEffects)i[r]=this._rendererEffects[r].getNetworkSyncData();const s={};for(const r in this._timers.items)s[r]=this._timers.items[r].getNetworkSyncData();return{x:this.x,y:this.y,zo:this.zOrder,a:this.angle,hid:this.hidden,lay:this.layer,if:this._instantForces.map(r=>r.getNetworkSyncData()),pfx:this._permanentForceX,pfy:this._permanentForceY,beh:e,var:t,eff:i,tim:s}}updateFromNetworkSyncData(e){if(e.x!==void 0&&this.setX(e.x),e.y!==void 0&&this.setY(e.y),e.zo!==void 0&&this.setZOrder(e.zo),e.a!==void 0&&this.setAngle(e.a),e.hid!==void 0&&this.hidden!==e.hid&&this.hide(e.hid),e.lay!==void 0&&this.layer!==e.lay&&this.setLayer(e.lay),e.if){this.clearForces();for(let t=0,i=e.if.length;tr()),this.clearEffects()}onDestroyed(){}onScenePaused(e){}onSceneResumed(e){}getRendererObject(){}get3DRendererObject(){}getName(){return this.name}getNameId(){return this._nameId}getUniqueId(){return this.id}setPosition(e,t){this.setX(e),this.setY(t)}setX(e){e!==this.x&&(this.x=e,this.invalidateHitboxes())}invalidateHitboxes(){this.hitBoxesDirty=!0,this._runtimeScene.onChildrenLocationChanged()}getX(){return this.x}setY(e){e!==this.y&&(this.y=e,this.invalidateHitboxes())}getY(){return this.y}getDrawableX(){return this.getX()}getDrawableY(){return this.getY()}rotateTowardPosition(e,t,i,s){this.rotateTowardAngle(n.toDegrees(Math.atan2(t-(this.getDrawableY()+this.getCenterY()),e-(this.getDrawableX()+this.getCenterX()))),i,s)}rotateTowardAngle(e,t,i){if(t===0){this.setAngle(e);return}const r=n.evtTools.common.angleDifference(this.getAngle(),e)>=0;let a=this.getAngle()+(r?-1:1)*t*this.getElapsedTime()/1e3;n.evtTools.common.angleDifference(a,e)>0^r&&(a=e),this.setAngle(a),this.getAngle()!==a&&this.setAngle(e)}rotate(e,t){this.setAngle(this.getAngle()+e*this.getElapsedTime()/1e3)}setAngle(e){this.angle!==e&&(this.angle=e,this.invalidateHitboxes())}getAngle(){return this.angle}setLayer(e){if(e===this.layer)return;const t=this._runtimeScene.getLayer(this.layer);this.layer=e;const i=this._runtimeScene.getLayer(this.layer),s=this.getRendererObject();s&&(t.getRenderer().removeRendererObject(s),i.getRenderer().addRendererObject(s,this.zOrder));const r=this.get3DRendererObject();r&&(t.getRenderer().remove3DRendererObject(r),i.getRenderer().add3DRendererObject(r))}getLayer(){return this.layer}isOnLayer(e){return this.layer===e}setZOrder(e){if(e===this.zOrder)return;this.zOrder=e;const t=this.getRendererObject();t&&this._runtimeScene.getLayer(this.layer).getRenderer().changeRendererObjectZOrder(t,e)}getZOrder(){return this.zOrder}getVariables(){return this._variables}static getVariableNumber(e){return e.getAsNumber()}static returnVariable(e){return e}static getVariableString(e){return e.getAsString()}static getVariableChildCount(e){return e.getChildrenCount()}static setVariableNumber(e,t){e.setNumber(t)}static setVariableString(e,t){e.setString(t)}static variableChildExists(e,t){return e.hasChild(t)}static variableRemoveChild(e,t){e.removeChild(t)}static variableClearChildren(e){e.clearChildren()}hasVariable(e){return this._variables.has(e)}getRendererEffects(){return this._rendererEffects}addEffect(e){return this.getRendererObject()?this._runtimeScene.getGame().getEffectsManager().addEffect(e,this._rendererEffects,this):!1}removeEffect(e){return this.getRendererObject()?this._runtimeScene.getGame().getEffectsManager().removeEffect(this._rendererEffects,this,e):!1}clearEffects(){const e=this.getRendererObject();return e?(this._rendererEffects={},this._runtimeScene.getGame().getEffectsManager().clearEffects(e)):!1}setEffectDoubleParameter(e,t,i){return this._runtimeScene.getGame().getEffectsManager().setEffectDoubleParameter(this._rendererEffects,e,t,i)}setEffectStringParameter(e,t,i){return this._runtimeScene.getGame().getEffectsManager().setEffectStringParameter(this._rendererEffects,e,t,i)}setEffectBooleanParameter(e,t,i){return this._runtimeScene.getGame().getEffectsManager().setEffectBooleanParameter(this._rendererEffects,e,t,i)}updateAllEffectParameters(e){return this._runtimeScene.getGame().getEffectsManager().updateAllEffectParameters(this._rendererEffects,e)}enableEffect(e,t){this._runtimeScene.getGame().getEffectsManager().enableEffect(this._rendererEffects,this,e,t)}isEffectEnabled(e){return this._runtimeScene.getGame().getEffectsManager().isEffectEnabled(this._rendererEffects,this,e)}hasEffect(e){return this._runtimeScene.getGame().getEffectsManager().hasEffect(this._rendererEffects,e)}hide(e){e===void 0&&(e=!0),this.hidden=e}isVisible(){return!this.hidden}isHidden(){return this.hidden}setWidth(e){}setHeight(e){}getWidth(){return 0}getHeight(){return 0}getCenterX(){return this.getWidth()/2}getCenterY(){return this.getHeight()/2}getCenterXInScene(){return this.getDrawableX()+this.getCenterX()}getCenterYInScene(){return this.getDrawableY()+this.getCenterY()}setCenterPositionInScene(e,t){this.setX(e+this.x-(this.getDrawableX()+this.getCenterX())),this.setY(t+this.y-(this.getDrawableY()+this.getCenterY()))}setCenterXInScene(e){this.setX(e+this.x-(this.getDrawableX()+this.getCenterX()))}setCenterYInScene(e){this.setY(e+this.y-(this.getDrawableY()+this.getCenterY()))}_getRecycledForce(e,t,i){if(o.forcesGarbage.length===0)return new n.Force(e,t,i);{const s=o.forcesGarbage.pop();return s.setX(e),s.setY(t),s.setMultiplier(i),s}}addForce(e,t,i){i===1?(this._permanentForceX+=e,this._permanentForceY+=t):i===0&&this._instantForces.length>0&&this._instantForces[0].getMultiplier()===0?this._instantForces[0].add(e,t):this._instantForces.push(this._getRecycledForce(e,t,i))}addPolarForce(e,t,i){const s=n.toRad(e),r=Math.cos(s)*t,a=Math.sin(s)*t;this.addForce(r,a,i)}addForceTowardPosition(e,t,i,s){const r=Math.atan2(t-(this.getDrawableY()+this.getCenterY()),e-(this.getDrawableX()+this.getCenterX())),a=Math.cos(r)*i,l=Math.sin(r)*i;this.addForce(a,l,s)}addForceTowardObject(e,t,i){e!=null&&this.addForceTowardPosition(e.getDrawableX()+e.getCenterX(),e.getDrawableY()+e.getCenterY(),t,i)}clearForces(){o.forcesGarbage.push.apply(o.forcesGarbage,this._instantForces),this._instantForces.length=0,this._permanentForceX=0,this._permanentForceY=0}hasNoForces(){return this._instantForces.length===0&&this._permanentForceX===0&&this._permanentForceY===0}updateForces(e){for(let t=0;t=t:(this._timers.put(e,new n.Timer(e)),!1)}timerPaused(e){return this._timers.containsKey(e)?this._timers.get(e).isPaused():!1}resetTimer(e){this._timers.containsKey(e)||this._timers.put(e,new n.Timer(e)),this._timers.get(e).reset()}pauseTimer(e){this._timers.containsKey(e)||this._timers.put(e,new n.Timer(e)),this._timers.get(e).setPaused(!0)}unpauseTimer(e){this._timers.containsKey(e)||this._timers.put(e,new n.Timer(e)),this._timers.get(e).setPaused(!1)}removeTimer(e){this._timers.containsKey(e)&&this._timers.remove(e)}getTimerElapsedTimeInSeconds(e){return this._timers.containsKey(e)?this._timers.get(e).getTime()/1e3:0}getTimerElapsedTimeInSecondsOrNaN(e){return this._timers.containsKey(e)?this._timers.get(e).getTime()/1e3:Number.NaN}separateFromObjects(e,t){let i=x.moveXArray,s=x.moveYArray;i.length=0,s.length=0;const r=this.getHitBoxes();let a=null;for(const l of e){if(l.id===this.id)continue;let h=l.getHitBoxes(),m=h;h.length>4&&(a||(a=this.getAABB()),m=l.getHitBoxesAround(a.min[0],a.min[1],a.max[0],a.max[1]));for(const g of r)for(const c of m){const u=n.Polygon.collisionTest(g,c,t);u.collision&&(i.push(u.move_axis[0]),s.push(u.move_axis[1]))}}return F(this,i,s)}separateFromObjectsList(e,t){let i=x.moveXArray,s=x.moveYArray;i.length=0,s.length=0;const r=this.getHitBoxes();let a=null;for(const l in e.items)if(e.items.hasOwnProperty(l)){const h=e.items[l];for(const m of h){if(m.id===this.id)continue;let g=m.getHitBoxes(),c=g;g.length>4&&(a||(a=this.getAABB()),c=m.getHitBoxesAround(a.min[0],a.min[1],a.max[0],a.max[1]));for(const u of r)for(const B of c){const v=n.Polygon.collisionTest(u,B,t);v.collision&&(i.push(v.move_axis[0]),s.push(v.move_axis[1]))}}}return F(this,i,s)}getDistanceToObject(e){return Math.sqrt(this.getSqDistanceToObject(e))}getSqDistanceToObject(e){if(e===null)return 0;const t=this.getDrawableX()+this.getCenterX()-(e.getDrawableX()+e.getCenterX()),i=this.getDrawableY()+this.getCenterY()-(e.getDrawableY()+e.getCenterY());return t*t+i*i}getDistanceToPosition(e,t){return Math.sqrt(this.getSqDistanceToPosition(e,t))}getSqDistanceToPosition(e,t){const i=this.getDrawableX()+this.getCenterX()-e,s=this.getDrawableY()+this.getCenterY()-t;return i*i+s*s}getAngleToObject(e){if(e===null)return 0;const t=this.getDrawableX()+this.getCenterX()-(e.getDrawableX()+e.getCenterX()),i=this.getDrawableY()+this.getCenterY()-(e.getDrawableY()+e.getCenterY());return n.toDegrees(Math.atan2(-i,-t))}getXFromAngleAndDistance(e,t){return this.getDrawableX()+this.getCenterX()+t*Math.cos(n.toRad(e))}getYFromAngleAndDistance(e,t){return this.getDrawableY()+this.getCenterY()+t*Math.sin(n.toRad(e))}getAngleToPosition(e,t){const i=this.getDrawableX()+this.getCenterX()-e,s=this.getDrawableY()+this.getCenterY()-t;return n.toDegrees(Math.atan2(-s,-i))}putAround(e,t,i,s){const r=n.toRad(s);this.setCenterXInScene(e+Math.cos(r)*i),this.setCenterYInScene(t+Math.sin(r)*i)}putAroundObject(e,t,i){!e||this.putAround(e.getDrawableX()+e.getCenterX(),e.getDrawableY()+e.getCenterY(),t,i)}separateObjectsWithoutForces(e){const t=n.staticArray(o.prototype.separateObjectsWithoutForces);t.length=0;const i=n.staticArray2(o.prototype.separateObjectsWithoutForces);e.values(i);for(let s=0,r=i.length;st[s].getDrawableX()+t[s].getWidth()&&this.setX(t[s].getDrawableX()+t[s].getWidth()),this.getDrawableY()t[s].getDrawableY()+t[s].getHeight()&&this.setY(t[s].getDrawableY()+t[s].getHeight()))}separateObjectsWithForces(e){const t=n.staticArray(o.prototype.separateObjectsWithForces);t.length=0;const i=n.staticArray2(o.prototype.separateObjectsWithForces);e.values(i);for(let s=0,r=i.length;sl+g)return!1;const y=e.getHitBoxesAround(B-g,v-g,B+g,v+g),d=t.getHitBoxesAround(c-l,u-l,c+l,u+l);for(const A of y)if(A!==s){for(const j of d)if(n.Polygon.collisionTest(A,j,i).collision)return!0}return!1}raycastTest(e,t,i,s,r){const a=this.getCenterX(),l=this.getCenterY(),h=_(this.getWidth(),this.getHeight(),a,l),m=(e+i)/2,g=(t+s)/2,c=(i-e)*(i-e)+(s-t)*(s-t),u=this.getDrawableX()+a-m,B=this.getDrawableY()+l-g;let v=D.result;if(v.collision=!1,u*u+B*B>h+c+2*Math.sqrt(c*h))return v;if(r){let p=Number.MAX_VALUE;const f=this.getHitBoxesAround(e,t,i,s);for(const y of f){const d=n.Polygon.raycastTest(y,e,t,i,s);d.collision&&d.closeSqDistp&&d.farSqDist<=c&&(p=d.farSqDist,n.Polygon.copyRaycastTestResult(d,v))}}return v}insideObject(e,t){return this.hitBoxesDirty&&(this.updateHitBoxes(),this.updateAABB(),this.hitBoxesDirty=!1),this.aabb.min[0]<=e&&this.aabb.max[0]>=e&&this.aabb.min[1]<=t&&this.aabb.max[1]>=t}static distanceTest(e,t,i){return e.getSqDistanceToObject(t)<=i}cursorOnObject(e){const t=n.staticArray(o.prototype.cursorOnObject);t.length=2;const i=e.getGame().getInputManager(),s=e.getLayer(this.layer),r=s.convertCoords(i.getCursorX(),i.getCursorY(),0,t);if(this.insideObject(r[0],r[1]))return!0;const a=i.getAllTouchIdentifiers();for(let l=0;ls[2]||o.min[1]>s[3]||o.max[0]{const o=r.getNetworkSyncData(t);o&&(n[s]=o)}),e!==void 0&&e!==1&&(!this.networkId||a.length===0&&!Object.keys(n).length)?null:{var:a,extVar:n,id:this.getOrCreateNetworkId()}}updateFromNetworkSyncData(t){if(t.var&&this._variables.updateFromNetworkSyncData(t.var),t.extVar)for(const e in t.extVar){if(!t.extVar.hasOwnProperty(e))continue;const a=t.extVar[e],n=this._variablesByExtensionName.get(e);n&&n.updateFromNetworkSyncData(a)}}getOrCreateNetworkId(){if(!this.networkId){const t=i.makeUuid().substring(0,8);this.networkId=t}return this.networkId}}i.RuntimeScene=c;let l;(function(s){s[s.CONTINUE=0]="CONTINUE",s[s.PUSH_SCENE=1]="PUSH_SCENE",s[s.POP_SCENE=2]="POP_SCENE",s[s.REPLACE_SCENE=3]="REPLACE_SCENE",s[s.CLEAR_SCENES=4]="CLEAR_SCENES",s[s.STOP_GAME=5]="STOP_GAME"})(l=i.SceneChangeRequest||(i.SceneChangeRequest={}))})(gdjs||(gdjs={})); +//# sourceMappingURL=runtimescene.js.map diff --git a/runtimewatermark.js b/runtimewatermark.js new file mode 100644 index 0000000000000000000000000000000000000000..8acd35057308ef2e0c567c04bf09207760ef64de --- /dev/null +++ b/runtimewatermark.js @@ -0,0 +1,100 @@ +var gdjs;(function(n){let a;(function(r){class s{constructor(e,t,i){this._linkElement=null;this._containerElement=null;this._backgroundElement=null;this._svgElement=null;this._usernameTextElement=null;this._madeWithTextElement=null;this._resizeObserver=null;this._displayDuration=20;this._changeTextDelay=7;this._fadeInDelayAfterGameLoaded=1;this._fadeDuration=.3;this._fadeOutTimeout=null;this._hideTimeout=null;this._fadeOutFirstTextTimeout=null;this._fadeInSecondTextTimeout=null;this._textFontSize=14;this._logoWidth=56;this._logoHeight=45;this._backgroundHeight=150;this._margin=10;this._gameId=e._data.properties.projectUuid,this._gameRenderer=e.getRenderer(),this._authorUsername=t[0],this._placement=i.placement,this._showAtStartup=i.showWatermark,this._isDevEnvironment=e.isUsingGDevelopDevelopmentEnvironment(),i.showWatermark&&this.addStyle()}displayAtStartup(){this._showAtStartup&&this.display()}display(){const e=this._gameRenderer.getDomElementContainer();e&&(this.addWatermarkToGameContainer(e),this._resizeObserver=new ResizeObserver(()=>{const t=e.getBoundingClientRect();this.onResizeGameContainer(t.height)}),this._resizeObserver.observe(e))}updateFontSize(e){this._textFontSize=Math.max(.025*e,12)}updateLogoSize(e){this._logoWidth=Math.max(.06*e,25),this._logoHeight=Math.round(45/56*this._logoWidth)}updateBackgroundHeight(e){this._backgroundHeight=Math.max(.13*e,45)}updateMargin(e){this._margin=Math.max(.025*e,8)}onResizeGameContainer(e){this.updateFontSize(e),this._madeWithTextElement&&(this._madeWithTextElement.style.fontSize=`${this._textFontSize}px`),this._usernameTextElement&&(this._usernameTextElement.style.fontSize=`${this._textFontSize}px`),this.updateLogoSize(e),this._svgElement&&(this._svgElement.setAttribute("height",this._logoHeight.toString()),this._svgElement.setAttribute("width",this._logoWidth.toString())),this.updateBackgroundHeight(e),this._backgroundElement&&(this._backgroundElement.style.height=`${this._backgroundHeight}px`),this.updateMargin(e),this._linkElement&&this.updateElementMargins(this._linkElement)}addWatermarkToGameContainer(e){const t=e.getBoundingClientRect();this.updateFontSize(t.height),this.updateLogoSize(t.height),this.updateBackgroundHeight(t.height),this._containerElement=this.createDivContainer(),this.createBackground();const i=document.createElement("div");this.generateSVGLogo(t.height),this.createMadeWithTextElement(),this.createUsernameTextElement(),this._linkElement=this.createLinkElement(),this._svgElement&&this._containerElement.appendChild(this._svgElement),this._madeWithTextElement&&i.appendChild(this._madeWithTextElement),this._usernameTextElement&&i.appendChild(this._usernameTextElement),this._containerElement.appendChild(i),this._backgroundElement&&e.appendChild(this._backgroundElement),this._linkElement.append(this._containerElement),e.appendChild(this._linkElement),this.setupAnimations()}createBackground(){this._backgroundElement=document.createElement("div"),this._backgroundElement.setAttribute("id","watermark-background"),this._backgroundElement.style.height=`${this._backgroundHeight}px`,this._backgroundElement.style.opacity="0",this._placement.startsWith("top")?(this._backgroundElement.style.top="0",this._backgroundElement.style.backgroundImage="linear-gradient(180deg, rgba(38, 38, 38, .6) 0%, rgba(38, 38, 38, 0) 100% )"):(this._backgroundElement.style.bottom="0",this._backgroundElement.style.backgroundImage="linear-gradient(0deg, rgba(38, 38, 38, .6) 0%, rgba(38, 38, 38, 0) 100% )")}setupAnimations(){requestAnimationFrame(()=>{setTimeout(()=>{!this._containerElement||!this._backgroundElement||!this._linkElement||(this._containerElement.style.opacity="1",this._backgroundElement.style.opacity="1",this._linkElement.style.pointerEvents="all",this._svgElement&&this._svgElement.classList.add("spinning"))},this._fadeInDelayAfterGameLoaded*1e3)}),this._fadeOutTimeout=setTimeout(()=>{!this._containerElement||!this._backgroundElement||(this._containerElement.style.opacity="0",this._backgroundElement.style.opacity="0",this._hideTimeout=setTimeout(()=>{!this._containerElement||!this._backgroundElement||!this._linkElement||(this._linkElement.style.pointerEvents="none",this._containerElement.style.display="none",this._backgroundElement.style.display="none",this._resizeObserver&&this._resizeObserver.disconnect())},this._fadeDuration*1e3))},(this._fadeInDelayAfterGameLoaded+this._displayDuration)*1e3),this._fadeOutFirstTextTimeout=setTimeout(()=>{const{_madeWithTextElement:e,_usernameTextElement:t}=this;!e||t&&(e.style.opacity="0",this._fadeInSecondTextTimeout=setTimeout(()=>{t.style.lineHeight="normal",t.style.opacity="1",e.style.lineHeight="0"},this._fadeDuration*1e3))},(this._fadeInDelayAfterGameLoaded+this._changeTextDelay)*1e3)}createMadeWithTextElement(){this._madeWithTextElement=document.createElement("span"),this._madeWithTextElement.innerText="Made with GDevelop",this._madeWithTextElement.style.fontSize=`${this._textFontSize}px`}createUsernameTextElement(){!this._authorUsername||(this._usernameTextElement=document.createElement("span"),this._usernameTextElement.innerText=`@${this._authorUsername}`,this._usernameTextElement.style.fontSize=`${this._textFontSize}px`,this._usernameTextElement.style.opacity="0",this._usernameTextElement.style.lineHeight="0")}updateElementMargins(e){switch(this._placement){case"top-left":e.style.top=`${this._margin}px`,e.style.left=`${this._margin}px`;break;case"top-right":e.style.top=`${this._margin}px`,e.style.right=`${this._margin}px`;break;case"bottom-left":e.style.bottom=`${this._margin}px`,e.style.left=`${this._margin}px`;break;case"bottom-right":e.style.bottom=`${this._margin}px`,e.style.right=`${this._margin}px`;break;case"top":e.style.top=`${this._margin}px`,e.style.left="50%",e.style.transform="translate(-50%, 0)";break;case"bottom":default:e.style.bottom=`${this._margin}px`,e.style.left="50%",e.style.transform="translate(-50%, 0)";break}}createLinkElement(){const e=document.createElement("a");e.id="watermark-link";let t=this._authorUsername?new URL(`https://gd.games/${this._authorUsername}`):new URL("https://gd.games");return this._isDevEnvironment?t.searchParams.set("dev","true"):(t.searchParams.set("utm_source","gdevelop-game"),t.searchParams.set("utm_medium","game-watermark"),this._gameId&&t.searchParams.set("utm_campaign",this._gameId)),e.href=t.href,e.target="_blank",this.updateElementMargins(e),e}createDivContainer(){const e=document.createElement("div");return e.setAttribute("id","watermark"),e.style.opacity="0",e}generateSVGLogo(e){this._svgElement=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.updateLogoSize(e),this._svgElement.setAttribute("height",this._logoHeight.toString()),this._svgElement.setAttribute("width",this._logoWidth.toString()),this._svgElement.setAttribute("viewBox","-2 -2 59 48"),this._svgElement.setAttribute("fill","none");const t=document.createElementNS("http://www.w3.org/2000/svg","path"),i=document.createElementNS("http://www.w3.org/2000/svg","path");t.setAttribute("d","M29.3447 33C25.1061 33 21.0255 31.8475 17.4207 29.3381C14.9081 27.5897 12 23.6418 12 16.9488C12 4.53178 18.3074 0 30.9827 0H53.8027L56 7.07232H32.7217C24.3558 7.07232 19.3813 7.72835 19.3813 16.9488C19.3813 19.9944 20.2354 22.1618 21.9933 23.574C24.9642 25.9612 30.7388 26.0628 34.2673 25.7208C34.2673 25.7208 35.715 21.0394 35.9534 20.2794C36.2327 19.3888 36.1104 19.1763 35.2392 19.1763C33.9808 19.1763 31.7185 19.1763 29.3175 19.1763C27.6349 19.1763 25.9818 18.3247 25.9818 16.2793C25.9818 14.3039 27.5198 13.1573 29.6281 13.1573C33.2786 13.1573 40.7969 13.1573 42.2041 13.1573C44.0489 13.1573 45.9315 13.4233 44.971 16.3601L39.8842 31.8734C39.8845 31.8738 35.7287 33 29.3447 33Z"),i.setAttribute("d","M43.3039 35.3278C40.7894 37.1212 37.0648 38.1124 30.7449 38.1124C19.852 38.1124 11.8797 34.1251 8.62927 26.3952C7.0925 22.7415 7.24041 18.6005 7.24041 13H0.00129513C0.00129513 18.9056 -0.0984386 23.5361 1.45249 27.8011C5.51933 38.989 15.992 45 30.0606 45C43.6783 45 49.3213 41.0443 53 35.3278H43.3039Z"),this._svgElement.appendChild(t),this._svgElement.appendChild(i)}addStyle(){const e=document.createElement("style");e.innerHTML=` + @keyframes spin { + 0% { + transform: rotate(0deg); + } + + 5% { + transform: rotate(-10deg); + animation-timing-function: ease-out; + } + + 17% { + transform: rotate(370deg); + animation-timing-function: ease-in-out; + } + + 20% { + transform: rotate(360deg); + animation-timing-function: ease-in-out; + } + + 100% { + transform: rotate(360deg); + } + } + + #watermark-background { + position: absolute; + pointer-events: none; + width: 100%; + transition-property: opacity; + transition-duration: ${this._fadeDuration}s; + } + + #watermark-link { + all: unset; + position: absolute; + cursor: pointer; + pointer-events: none; + user-select: none; + + /* For Safari */ + -webkit-user-select: none; + } + + #watermark { + display: flex; + flex-direction: row; + align-items: center; + transition-property: opacity; + transition-duration: ${this._fadeDuration}s; + transition-timing-function: ease-out; + } + + #watermark > div { + display: flex; + flex-direction: column; + margin-left: 5px; + } + + #watermark span { + color: white; + font-family: 'Tahoma', 'Gill sans', 'Helvetica', 'Arial'; + font-size: ${this._textFontSize}px; + transition: opacity; + transition-duration: ${this._fadeDuration}s; + + /* For Safari */ + -webkit-transition: opacity; + -webkit-transition-duration: ${this._fadeDuration}s; + } + + #watermark svg.spinning { + animation-name: spin; + animation-direction: normal; + animation-duration: 5s; + animation-iteration-count: 3; + animation-delay: 1.5s; + } + + #watermark svg path { + fill: white; + } + + @media (hover: hover) { + #watermark span { + text-decoration: underline; + text-decoration-style: solid; + text-decoration-color: transparent; + } + + #watermark:hover span { + text-decoration-color: white; + + /* For Safari */ + -webkit-text-decoration-color: white; + } + } + `,document.head.appendChild(e)}}r.RuntimeWatermark=s})(a=n.watermark||(n.watermark={}))})(gdjs||(gdjs={})); +//# sourceMappingURL=runtimewatermark.js.map diff --git a/scenestack.js b/scenestack.js new file mode 100644 index 0000000000000000000000000000000000000000..9c7614bd1ae2ce31dcfb0acf70bd8e3349856478 --- /dev/null +++ b/scenestack.js @@ -0,0 +1,2 @@ +var gdjs;(function(o){const r=new o.Logger("Scene stack"),c=new o.Logger("Multiplayer - Debug");class h{constructor(t){this._stack=[];this._wasFirstSceneLoaded=!1;this._isNextLayoutLoading=!1;this._sceneStackSyncDataToApply=null;this._wasDisposed=!1;if(!t)throw"SceneStack must be constructed with a gdjs.RuntimeGame.";this._runtimeGame=t}onGameResolutionResized(){for(let t=0;t{this._loadNewScene(t),this._isNextLayoutLoading=!1}),null)}_loadNewScene(t,s){this._throwIfDisposed();const e=new o.RuntimeScene(this._runtimeGame);if(e.loadFromScene(this._runtimeGame.getSceneAndExtensionsData(t)),this._wasFirstSceneLoaded=!0,s){const n=this._runtimeGame.getExternalLayoutData(s);n&&e.createObjectsFrom(n.instances,0,0,0,!0)}return this._stack.push(e),e}replace(t,s){if(this._throwIfDisposed(),s)for(;this._stack.length!==0;){let e=this._stack.pop();e&&e.unloadScene()}else if(this._stack.length!==0){let e=this._stack.pop();e&&e.unloadScene()}return this.push(t)}getCurrentScene(){return this._throwIfDisposed(),this._stack.length===0?null:this._stack[this._stack.length-1]}wasFirstSceneLoaded(){return this._wasFirstSceneLoaded}getAllSceneNames(){return this._throwIfDisposed(),this._stack.map(t=>t.getName())}getNetworkSyncData(t){const s=t.playerNumber,e=t.isHost;if(s!==void 0&&!e)return null;const n=[];for(let a=0;at.length){const e=this._stack.length-t.length;this.pop(e),s=!0}return s}dispose(){for(const t of this._stack)t.unloadScene();this._stack.length=0,this._wasDisposed=!0}_throwIfDisposed(){if(this._wasDisposed)throw"The scene stack has been disposed and should not be used anymore."}}o.SceneStack=h})(gdjs||(gdjs={})); +//# sourceMappingURL=scenestack.js.map diff --git a/splash/gd-logo-light.js b/splash/gd-logo-light.js new file mode 100644 index 0000000000000000000000000000000000000000..55b931efe303522cfae8e316335b318c63b8dcea --- /dev/null +++ b/splash/gd-logo-light.js @@ -0,0 +1,2 @@ +var gdjs;(function(z){z.gdevelopLogo="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAvMAAACECAMAAAAqY1S1AAAAPFBMVEUAAAD////////////////////////////////////////////////////////////////////////////YSWgTAAAAE3RSTlMAgN8gYECfv+8QcKCQzzBQrx+wpZQyXAAAEDxJREFUeNrs3Olu6yAQBWCYwWxe7533f9cqilK3qiHY9VZ0vn+REsWSD2iMBxScKQwmaju5nsjLLqICuKfQRNt72Z1TAPcTjCU5iA8K4F5YOzmSUQA3EqKTg1kFcBvceTmcVwA3wVZO0SiAOwhaTtIpgBtoSJJQ3EB9Qic5KG6gNkxyJq0ArjV4ORUpgEuNXk72TwFcqJEV0GcGfx97KYM+M6gDk1wAfWZwnV7KoLiBSmgpg+IGKsFSDk30UAOSNdBED3+ekULUO2ttp3czKoArkLxDNpoBhQjUwkiW70akHepCkuHQ/QjVMZI2sQKojpMUwhwPNWJJcSjjoUpGEloFUCUnyyYFUKUgywiFDVRqlGVYsIFadThZ7zChidYRkXNdHBTcRX/uNM/yk+9dN7LKkLca5cp2odCX3ed6xTb1dv5YqHFeviDLqzq5fY+RcpCTp3mWFLL8q8xHeYhFu37t8Zk3JD+4oTDzM7J4R7K35uTjllgynPlF5kPRLhT7/PbRmWcniyyXZn5GaLjeVzz55BmWrIk3Z/5Z3PhQVNocnPno5wplstb18kJcnPmZxYLCnrqTj0/lZ7T1V93UyyedzLzTGfwavqawtJmzpjPihszPGe718PnHLSW2yaSu49tIQeh35E4+SZKX73sYW58Zb89MFL1psAVDvPmWNZWzJfN6uVvJUCL0yesIYytPHg+zRWhJLFq2CWpZ001Uyk2G32d+xq9M9GFT5l/FTUlpc2jmdWrs8pSYUTLXwS1eEa5QdC6qlwV9fiminE5lPnt/3cbM6zlRCYM82EMzb+TBm/QVen6f+Vnj0Qqya+aDLPmvFgQn68VE5vPPft22zPP843xpc2TmmeThg72zXXMTBKJw5BsWNFnv/15bkzYHBcwIkqZPO792g8KoL3AYAXejkprAPGw08Lq/jVLyy9sNhdvuzHPCQS27Phl7gHk8X5dnvlncBIDbi3m1/5rAR8lUP9w79wJieDpvNBQuuzMvyTtwDHOVjQeYh0OGE5mnixsUrnoyL170NZahKSD6sYnC8p9WagxxwKcyz73nH8m8PG/XJ3mIeTRqVcxLHLeTt+zFPAbJluIjnXkR3zTUqZ2KrT6VeYbK+6eYn6jMi7cwj+ipPMo8iAsEadOFedD5MiNjjzBv484Dp+dNfDLz98c/vZt5Csq3nA6ts2N6HpuC6yrmB7hfljY9mQ+vj+K4GLIfIYosvJpWxD6Z+bt3HPgNw/i5zOs65AM1bpOq8hrm5S4QAhl3Yn7E1b1q6InMp4W/GNBO80czz72SK6rEhzBvT2PeVTCPnpzKPIztAaFBTifmFeUgiapH9cNH1QSasXSR5oOZX+wjmc8+8irjdOZhV0jWo8x71NmStGlnvlVXMJofhQOWSo1XVLmLHP4zfwrz7hxpA+bpDSGYbxA3kDZtzJMdJ7Ta1cwv5dhiT6P/M3+OnrdVzPsq5i8G5x5gHqdqgrTpwbxDfoSqUa/nl0sZysj+Z76e+fbAzXiYeYgbVsW8hy7KS5uezGtUuNcDFkfzAxkHMO9Kr5vF4uM/zLypZh6owmxo/egxnXkHVX6EebShU1na9GTeUNxE6JHuh1nHKi/WJHCA2BzzXAxKDU4Wl6qrQYwl5kfnlce572DeikH54fh+2Kz6PeyUvTNfjdKGzvwIL44wDzxUufPoxTzcPpYX/CCOUpZ+eDlDFw7kCfN2eKJgsOQKqQaLEDPMu/BqwbLePmm3/WH43Us9feMplmBe6toVYoywuHs88jk/oZulDZind/5gni5uSnmqnsxPuGhSP0b2Q/3KGMzz/FhZLVe4ZV6uQDBuQ0CcqjmYzySzqXQ5bNuPmaRWkJm3Pi5yPJ15Tmyf0QsOqX0xorQB8/RoXpl5euwEQMpW5tuHsKgcVD/4r7sJ5kFRcqAEV1HmWoycS3HFfYwnsoZhknLybJ4ZXzMvzOPk3+e6kn+3rb9y097INfNWLWbmWavFJjBvlxrjJynlwDDdsJ152CmfsBRUaQPmKYPBKuYR9Cm/Lmpnnt7FlCGeqH6E5z0D8xIj9VWlC+AKFVFzzO5f48hZ3PI7M+sV8xNOxrlZ0twWh2Fdx80FzO/r+SUmZXH0MRg1ZTkIO+MTlo4sbcA8HTAwT4fTFHR+L+YxYghk5gXND6vQzIN5cJbEXBZXVVzU12Yus167PMZVYOUYN6uTbShMGfVrrvRsDPxFOol5PRu5bkZurczr9Dm1rwFXNGlDZ96DWzB/FRmzNHEDaZMyLzImS8y3hypRh0nMjwFxBTB/P0fnApUb5hWcxu2R8T8uGd+JCI6wnf435PWkWT1iHVaoBuT5gvlEFRk4mDUKzqzHXh+Gkgmd+RQCylxl3CYAlUgb6joYXc3896nMS4VB3op5hCtX5SswD9zKQkRn5Z6I2gm+SU17UPiCqueG2GOOfAjMD2kXQrcvCvNibhc3kiht+jOP6w7ZUXE35tMySEeWmbecT04ZxDW2zF88vIzQ2jKf3KJHKs4QKb4CRKo9uFfsDnFby2XsnMA/r5lnPOm7mrdroq1/ch2kDZF51MRbFfM4ORU8H8182Yxb9xHj70uyaaASVKcG6nCnbG5MgDqU3gWfH9DpKEgT7tnYyDFHZl6l7SkRw/KdvJF0CbPN39pUzczb48xD3LictPk7mdd8o4skGte12JZ05tFVlJgXC7wp3N+FFyoWimi4l+KiLEcy8zJ9gdQcQRxpk4SHDtu8NmobzzNmaWNJQJYWw3P2Ocxr3Egwj5FjogLIzCPIn2deZVKnwj0IGGSrO2ORuBlxzhHmwUvzF0QELbZueKOGYpezmR+OVXabkzZdY5UBJFeMYXPGVBqYwoUYgAZY6cyX451PIF0xQpMy4J8ZsF/O2WffoPoxXzOvoP17UiEvbZqZN5XMY+pCKm3ozL8/VjnE5oSY0IllmN+GKyUeWco8F/4a2MMMUpFVjnlWIKPQ17PnX3f6fVx3pncxz2ks6jlvwTYUA9/f/U4K8CVaoifzCBiRK6Wo8gOgIoqCESyYL8+TojJvaMw/D7799kP+Yl89k2w/5qv2onQzFfr2Hez7zz2AS8ZuejzZm3mPQ0jzRuuZR1TQrwKVYD6ZYsau6mGByPySelUZK90eB2mzmLk/ASj7TsyT5hVkwhwFY7x+N29VzTwmmFczb8H4FsaPmGMmEU1oYl6iZiuQtWZePMbBFoURmEcqzRCDH5+5+/vpiOC8h/lrIXBDXwE11EubaubBeBXzqIcqJ236zyW+kecStzKPcCVQBfPoUoJMxrAYBO/q+elIM2NAeizsNZB7A/Oe9rpJNn3LSNCkTf81I6m4WZcpuzPPI7cpIqiReUykRKASzIOiYHfiNqLMfEAqwfTDrQA/zP0JWHjWgXkijt80dQLqeUVnoqqZh+M8Yb5S3LgE155rAz2xG/puZx6jWMAD5rFwqsT8tRSfxztXsj1m2PBfmaPJn/BLO/O1ssMU5GXZ9A72liht+q8BT6nyubj5B6wBx+W0MY9w5Qi0wTymaNW9h3XkqS4Yqrp7PwdxgzhOX+Zhhsijnl9ZUE5a+osvdqlmHvq7gXmIG0ibvswjP0NdytXKPF76I1AJ5iH4c8xjLcf+fBt5CDa7TJ2PgyPs3uBc3sn8lbrpjJkpxrQa3CTlyO8mpRADIWpTuafTVMd8yrlY0/o37umUZR5QL1c7UplnSLWZQex6XqU+NI1X8Ee3gl9uHHm8h3lHnSg8zOeabGJegYka5tF1DfhTdWeeLugZ5HwL8whXCoC1Yf4LKWACN+OaJIvo6YjMk7R7gzAlHifDNzfhlzzzro15qlCfcgHxM41dapnHIaqaeWCkkZ3szjxacNrmxc3MI7ry1CNgHoQbmxT+XVwnxVnsmk7e0YxB7ozsglr0TSxuvv088xzzGERTmG8X9Dq76fs5lvLafy/ucjk3SJv+zEOVkTYvbmYeVCO7LfN287iFAQCU9bAb6KXZ3RHZsFlvfglzyI4mMIg+m3lPlh6uu7Tp/82FVNw4SJs3MI/IDbkba2feQk+tmAcBmH8vl4Z7tULWLpDH+x6wVZ8hVl/9tMPrLxeJJObs88xDPZ3MvCyuiOgp6dmlhXlF+LYOWdxA2ryHeYHS9q+Pn8E82jWeYx5bLl7dJIRf/mRczLPZtOzMT3IS3izJOt3fZknmUiiz/xBGOBLXR5lnHgeoaRKumXmYoTfEXz2lDZ15hyyqmUd1t1lp0/8bauRmvp35Ednl5tvYH+3d63KqMBSG4WQlIQfCYWbd/71u97Tdyz0a0AAR7ff8pa3WecUQCcx8ZY5q/B7zSfRiMGpmtqqwmUNaic3f3gBClZuX4QXt2Hwu7eiPjN7VNi83iDWbmpf6kpolsRbNT2vXjSD5/7Y2L2G52+aFpZ9iO/c9xP8v3UQ/VdivX7aFKzYGHddis0tLCaV5kWj35l0pywOjJ1XfvKGqeyKXBzdyFkKb5pWXw9jyQ+qa51HPTFrr5IrFuqS1tkYVRNm+v/j13NSO/DOroDTvoatv3gX5C1ubd3wRkqR6fPNyCB7GpUek+88D9pGeOkvYEm831TYfsyxW2da8HMvIaQwtmpdXPIzlBwwGzR+ovCJkvJ9kz1sFVdd8tCTJ79F85h+uXfPyaamL7+lJoflD6fIa72N29V1V8y4H/uKj2qd5JwcYDZuX4yJy919ZrdD8jTY7+lyqMh82tJGpOnsl6W4Ii4MuuUZr2VSeqO2Wm7eLzHXIwRY5JfLtSdijDvwlKTR/NL10v+L9BzhBrTdf5p26p2a2SNJz5ZdmnZXmF3X3/zD57kLe08EpNH+r1Y4+jOqA6ruq5mWCeMfmnWxp07wwVLwMH5pvQNdc18D0gatMtc2H7JTY0LwIUmOj5oWl+59iaL6B2ot5ROurhjYVzdPQJclhn+ZlcOOaNi/k9ZNvQdF8I4mfil6YNDwX/JCdWmFuRLXKPEDdioUNsn1dfPBno7oVp+wHurheWll+nrCj4dnohbE98QNoznZUACfhuCJ6YSY9D3xXIN/lNJmoAE4lcxGN6jHROZv0N2vt5PBxDOcVicuSAvg8jhdkjEzgA2VeQBikwAcaeIlWAJ/GBF5CkwL4MI6XdRjgwKfRjOrhl8ncsvrRU9mAqSJooudVnVMbyTo4fCcALxcHXkfWbH8gHXhJpwAKWkYvvDWbi8f3AXAOEv0Kn0ZVtvG0e5yACWXtoxfU2WfjNMkH/gtfgMGJ9PyE4PPk4kO5T2n+2zuSh/PR/CzynbbO3V+K5GzKsrB/3awA1rw+eqmfBv+DiAI/DTPz8AqO+FUIycNLmIFfY8AsJTzuNOObfzCwgbcyEjfXI3l4pZh5P5ikhLdgiBsKWJUCJ2DbVe9x9AqnYDI3EXDyMJyG6fkWdvLw0Q6vnpwCOBfTE1/BsAZ+AzvwIShhTh7OajxgZ+8xqoFzm/rA+yGNXTy8AdfTTsFjFw9vY5QFT3XCnDA3Ce/m0v3ANahLWOEN7yq6lH14vPY5J4cRPLy/OE4pz34oxB9omDttcUcp+ETRjO5ishfuYjQIvak/vlvA3mF1abkAAAAASUVORK5CYII="})(gdjs||(gdjs={})); +//# sourceMappingURL=gd-logo-light.js.map diff --git a/spriteruntimeobject.js b/spriteruntimeobject.js new file mode 100644 index 0000000000000000000000000000000000000000..34c25ac87935e38d1c2f6440347efbf57f554dd9 --- /dev/null +++ b/spriteruntimeobject.js @@ -0,0 +1,2 @@ +var gdjs;(function(n){class s extends n.RuntimeObject{constructor(t,e){super(t,e);this._scaleX=1;this._scaleY=1;this._blendMode=0;this._flippedX=!1;this._flippedY=!1;this.opacity=255;this._preScale=1;this._animationFrameDirty=!0;this._updateIfNotVisible=!!e.updateIfNotVisible,this._preScale=e.preScale||1,this._renderer=new n.SpriteRuntimeObjectRenderer(this,t),this._animator=new n.SpriteAnimator(e.animations,n.SpriteRuntimeObjectRenderer.getAnimationFrameTextureManager(t.getGame().getImageManager())),this._updateAnimationFrame(),this.onCreated()}reinitialize(t){super.reinitialize(t);const e=this.getInstanceContainer();this._animator.reinitialize(t.animations),this._scaleX=1,this._scaleY=1,this._blendMode=0,this._flippedX=!1,this._flippedY=!1,this.opacity=255,this._updateIfNotVisible=!!t.updateIfNotVisible,this._preScale=t.preScale||1,this._renderer.reinitialize(this,e),this._updateAnimationFrame(),this.onCreated()}updateFromObjectData(t,e){return this._preScale=e.preScale||1,this._animator.updateFromObjectData(t.animations,e.animations),this._updateIfNotVisible=!!e.updateIfNotVisible,this._updateAnimationFrame(),this.invalidateHitboxes(),!0}getNetworkSyncData(){return{...super.getNetworkSyncData(),anim:this._animator.getNetworkSyncData(),ifx:this.isFlippedX(),ify:this.isFlippedY(),sx:this._scaleX,sy:this._scaleY,op:this.opacity,color:this.getColor()}}updateFromNetworkSyncData(t){super.updateFromNetworkSyncData(t),t.ifx!==void 0&&this.flipX(t.ifx),t.ify!==void 0&&this.flipY(t.ify),t.sx!==void 0&&this.setScaleX(Math.abs(t.sx)),t.sy!==void 0&&this.setScaleY(Math.abs(t.sy)),t.op!==void 0&&this.setOpacity(t.op),t.anim&&(this._animator.updateFromNetworkSyncData(t.anim),this._updateAnimationFrame()),(t.ifx!==void 0||t.ify!==void 0||t.sx!==void 0||t.sy!==void 0||t.anim!==void 0)&&this.invalidateHitboxes(),t.color!==void 0&&this.setColor(t.color)}extraInitializationFromInitialInstance(t){if(t.numberProperties)for(let e=0,i=t.numberProperties.length;e=this.hitBoxes.length&&this.hitBoxes.push(new n.Polygon);for(let i=0;i=this.hitBoxes[e].vertices.length&&this.hitBoxes[e].vertices.push([0,0]),this._transformToGlobal(t.customHitBoxes[e].vertices[i][0],t.customHitBoxes[e].vertices[i][1],this.hitBoxes[e].vertices[i]);this.hitBoxes[e].vertices.length=t.customHitBoxes[e].vertices.length}this.hitBoxes.length=t.customHitBoxes.length}}setAnimation(t){this.setAnimationIndex(t)}setAnimationIndex(t){this._animator.setAnimationIndex(t)&&(this._renderer.update(),this._animationFrameDirty=!0,this.invalidateHitboxes())}setAnimationName(t){this._animator.setAnimationName(t)&&(this._renderer.update(),this._animationFrameDirty=!0,this.invalidateHitboxes())}getAnimation(){return this.getAnimationIndex()}getAnimationIndex(){return this._animator.getAnimationIndex()}getAnimationName(){return this._animator.getAnimationName()}isCurrentAnimationName(t){return this.getAnimationName()===t}setDirectionOrAngle(t){const e=this._animator.setDirectionOrAngle(this.angle,t);e!==null&&(this.angle=e,this._renderer.update(),this._animationFrameDirty=!0,this.invalidateHitboxes(),this._renderer.updateAngle())}getDirectionOrAngle(){return this._animator.getDirectionOrAngle(this.angle)}setAnimationFrame(t){this._animator.setAnimationFrameIndex(t)&&(this._animationFrameDirty=!0,this.invalidateHitboxes())}getAnimationFrame(){return this._animator.getAnimationFrameIndex()}getAnimationElapsedTime(){return this._animator.getAnimationElapsedTime()}setAnimationElapsedTime(t){this._animator.setAnimationElapsedTime(t)&&(this._animationFrameDirty=!0,this.invalidateHitboxes())}getAnimationDuration(){return this._animator.getAnimationDuration()}getAnimationFrameCount(){return this._animator.getAnimationFrameCount()}hasAnimationEndedLegacy(){return this._animator.hasAnimationEndedLegacy()}hasAnimationEnded2(){return this._animator.hasAnimationEnded()}hasAnimationEnded(){return this._animator.hasAnimationEnded()}animationPaused(){return this._animator.isAnimationPaused()}isAnimationPaused(){return this._animator.isAnimationPaused()}pauseAnimation(){this._animator.pauseAnimation()}playAnimation(){this._animator.resumeAnimation()}resumeAnimation(){this._animator.resumeAnimation()}getAnimationSpeedScale(){return this._animator.getAnimationSpeedScale()}setAnimationSpeedScale(t){this._animator.setAnimationSpeedScale(t)}getPointX(t){const e=this._animator.getCurrentFrame();if(t.length===0||e===null)return this.getX();const i=e.getPoint(t),a=n.staticArray(s.prototype.getPointX);return this._transformToGlobal(i.x,i.y,a),a[0]}getPointY(t){const e=this._animator.getCurrentFrame();if(t.length===0||e===null)return this.getY();const i=e.getPoint(t),a=n.staticArray(s.prototype.getPointY);return this._transformToGlobal(i.x,i.y,a),a[1]}getPointPosition(t){const e=this._animator.getCurrentFrame();if(t.length===0||e===null)return[this.getX(),this.getY()];const i=e.getPoint(t),a=n.staticArray(s.prototype.getPointX);return this._transformToGlobal(i.x,i.y,a),[a[0],a[1]]}_transformToGlobal(t,e,i){const a=this._animator.getCurrentFrame();let r=a.center.x,o=a.center.y;this._flippedX&&(t=t+(r-t)*2),this._flippedY&&(e=e+(o-e)*2);const h=Math.abs(this._scaleX*this._preScale),l=Math.abs(this._scaleY*this._preScale);t*=h,e*=l,r*=h,o*=l;const d=this.angle/180*Math.PI,m=Math.cos(d),p=Math.sin(d),u=t-r,f=e-o;t=r+m*u-p*f,e=o+p*u+m*f,i.length=2,i[0]=t+(this.x-a.origin.x*h),i[1]=e+(this.y-a.origin.y*l)}getDrawableX(){const t=this._animator.getCurrentFrame();if(t===null)return this.x;const e=Math.abs(this._scaleX*this._preScale);return this._flippedX?this.x+(-t.origin.x-this._renderer.getUnscaledWidth()+2*t.center.x)*e:this.x-t.origin.x*e}getDrawableY(){const t=this._animator.getCurrentFrame();if(t===null)return this.y;const e=Math.abs(this._scaleY*this._preScale);return this._flippedY?this.y+(-t.origin.y-this._renderer.getUnscaledHeight()+2*t.center.y)*e:this.y-t.origin.y*e}getCenterX(){const t=this._animator.getCurrentFrame();return t===null?0:this._flippedX?(this._renderer.getUnscaledWidth()-t.center.x)*Math.abs(this._scaleX*this._preScale):t.center.x*Math.abs(this._scaleX*this._preScale)}getCenterY(){const t=this._animator.getCurrentFrame();return t===null?0:this._flippedY?(this._renderer.getUnscaledHeight()-t.center.y)*Math.abs(this._scaleY*this._preScale):t.center.y*Math.abs(this._scaleY*this._preScale)}setX(t){if(t===this.x)return;this.x=t,this._animator.getCurrentFrame()!==null&&(this.invalidateHitboxes(),this._renderer.updateX())}setY(t){if(t===this.y)return;this.y=t,this._animator.getCurrentFrame()!==null&&(this.invalidateHitboxes(),this._renderer.updateY())}setAngle(t){const e=this._animator.setAngle(this.angle,t);e!==null&&(this.angle=e,this.invalidateHitboxes(),this._renderer.updateAngle())}getAngle(){return this._animator.getAngle(this.angle)}setBlendMode(t){this._blendMode!==t&&(this._blendMode=t,this._renderer.update())}getBlendMode(){return this._blendMode}setOpacity(t){t<0&&(t=0),t>255&&(t=255),this.opacity=t,this._renderer.updateOpacity()}getOpacity(){return this.opacity}hide(t){t===void 0&&(t=!0),this.hidden=t,this._renderer.updateVisibility()}setColor(t){this._renderer.setColor(t)}getColor(){return this._renderer.getColor()}flipX(t){t!==this._flippedX&&(this._scaleX*=-1,this._flippedX=t,this.invalidateHitboxes(),this._renderer.update())}flipY(t){t!==this._flippedY&&(this._scaleY*=-1,this._flippedY=t,this.invalidateHitboxes(),this._renderer.update())}isFlippedX(){return this._flippedX}isFlippedY(){return this._flippedY}getWidth(){return this._animationFrameDirty&&this._updateAnimationFrame(),this._renderer.getWidth()}getHeight(){return this._animationFrameDirty&&this._updateAnimationFrame(),this._renderer.getHeight()}setWidth(t){this._animationFrameDirty&&this._updateAnimationFrame();const e=this._renderer.getUnscaledWidth();e!==0&&this.setScaleX(t/(e*this._preScale))}setHeight(t){this._animationFrameDirty&&this._updateAnimationFrame();const e=this._renderer.getUnscaledHeight();e!==0&&this.setScaleY(t/(e*this._preScale))}setSize(t,e){this.setWidth(t),this.setHeight(e)}setScale(t){t<0&&(t=0),!(t===Math.abs(this._scaleX)&&t===Math.abs(this._scaleY))&&(this._scaleX=t*(this._flippedX?-1:1),this._scaleY=t*(this._flippedY?-1:1),this._renderer.update(),this.invalidateHitboxes())}setScaleX(t){t<0&&(t=0),t!==Math.abs(this._scaleX)&&(this._scaleX=t*(this._flippedX?-1:1),this._renderer.update(),this.invalidateHitboxes())}setScaleY(t){t<0&&(t=0),t!==Math.abs(this._scaleY)&&(this._scaleY=t*(this._flippedY?-1:1),this._renderer.update(),this.invalidateHitboxes())}getScaleMean(){return(Math.abs(this._scaleX)+Math.abs(this._scaleY))/2}getScale(){const t=Math.abs(this._scaleX),e=Math.abs(this._scaleY);return t===e?t:Math.sqrt(t*e)}getScaleY(){return Math.abs(this._scaleY)}getScaleX(){return Math.abs(this._scaleX)}turnTowardObject(t,e){t!==null&&this.rotateTowardPosition(t.getDrawableX()+t.getCenterX(),t.getDrawableY()+t.getCenterY(),0,e)}}n.SpriteRuntimeObject=s,n.registerObject("Sprite",n.SpriteRuntimeObject),s.supportsReinitialization=!0})(gdjs||(gdjs={})); +//# sourceMappingURL=spriteruntimeobject.js.map diff --git a/timemanager.js b/timemanager.js new file mode 100644 index 0000000000000000000000000000000000000000..cbf80542cc40beea30bcf911dca116e0ea605fcb --- /dev/null +++ b/timemanager.js @@ -0,0 +1,2 @@ +var gdjs;(function(i){class r{constructor(){this._elapsedTime=0;this._timeScale=1;this._timeFromStart=0;this._firstFrame=!0;this._timers=new Hashtable;this._firstUpdateDone=!1;this.reset()}reset(){this._elapsedTime=0,this._timeScale=1,this._timeFromStart=0,this._firstFrame=!0,this._timers=new Hashtable}update(e,s){this._firstUpdateDone&&(this._firstFrame=!1),this._firstUpdateDone=!0,this._elapsedTime=Math.min(e,1e3/s),this._elapsedTime*=this._timeScale;for(const t in this._timers.items)this._timers.items.hasOwnProperty(t)&&this._timers.items[t].updateTime(this._elapsedTime);this._timeFromStart+=this._elapsedTime}setTimeScale(e){e>=0&&(this._timeScale=e)}getTimeScale(){return this._timeScale}getTimeFromStart(){return this._timeFromStart}isFirstFrame(){return this._firstFrame}getElapsedTime(){return this._elapsedTime}addTimer(e){this._timers.put(e,new i.Timer(e))}hasTimer(e){return this._timers.containsKey(e)}getTimer(e){return this._timers.get(e)}removeTimer(e){this._timers.containsKey(e)&&this._timers.remove(e)}}i.TimeManager=r})(gdjs||(gdjs={})); +//# sourceMappingURL=timemanager.js.map diff --git a/timer.js b/timer.js new file mode 100644 index 0000000000000000000000000000000000000000..6d8ff116d1efbdbb26b065ae887ec171b202dce1 --- /dev/null +++ b/timer.js @@ -0,0 +1,2 @@ +var gdjs;(function(i){class t{constructor(e){this._time=0;this._paused=!1;this._name=e}getName(){return this._name}getTime(){return this._time}updateTime(e){this._paused||(this._time+=e)}setTime(e){this._time=e}reset(){this.setTime(0)}setPaused(e){this._paused=e}isPaused(){return this._paused}getNetworkSyncData(){return{time:this._time,paused:this._paused}}updateFromNetworkSyncData(e){this._time=e.time,this._paused=e.paused}}i.Timer=t})(gdjs||(gdjs={})); +//# sourceMappingURL=timer.js.map diff --git a/variable.js b/variable.js new file mode 100644 index 0000000000000000000000000000000000000000..c7aac5eb829d5ef0360f8e5a675a9bade0ed4a48 --- /dev/null +++ b/variable.js @@ -0,0 +1,2 @@ +var gdjs;(function(i){const n=new i.Logger("Variables");class l{constructor(e){this._type="number";this._value=0;this._str="0";this._bool=!1;this._children={};this._childrenArray=[];this._undefinedInContainer=!1;this._playerNumber=0;this.reinitialize(e)}reinitialize(e){if(this._type="number",this._value=0,this._str="0",this._bool=!1,this._children={},this._childrenArray=[],this._undefinedInContainer=!1,e!==void 0){if(this._type=e.type||"number",this._type==="number")this._value=parseFloat(e.value||"0"),this._value!==this._value&&(this._value=0);else if(this._type==="string")this._str=""+e.value||"0";else if(this._type==="boolean")this._bool=!!e.value;else if(this._type==="structure"){if(e.children!==void 0)for(var t=0,r=e.children.length;tNumber.MAX_SAFE_INTEGER&&n.warn("Error while converting JS variable to GDevelop variable: Integers bigger than "+Number.MAX_SAFE_INTEGER+" aren't supported by GDevelop variables, it will be reduced to that size."),variable.setNumber(parseInt(e,10))):typeof e=="function"?n.error("Error while converting JS variable to GDevelop variable: Impossible to set variable value to a function."):n.error("Error while converting JS variable to GDevelop variable: Cannot identify type of object "+e);return this}fromJSON(e){try{var t=JSON.parse(e)}catch(r){return n.error("Unable to parse JSON: "+e+r),this}return this.fromJSObject(t),this}toJSObject(){switch(this._type){case"string":return this.getAsString();case"number":return this.getAsNumber();case"boolean":return this.getAsBoolean();case"structure":const e={};for(const r in this._children)e[r]=this._children[r].toJSObject();return e;case"array":const t=[];for(const r of this._childrenArray)t.push(r===void 0?void 0:r.toJSObject());return t}}isPrimitive(){return i.Variable.isPrimitive(this._type)}clone(){return i.Variable.copy(this,new i.Variable)}setUndefinedInContainer(){this._undefinedInContainer=!0}isUndefinedInContainer(){return this._undefinedInContainer}castTo(e){if(e==="string")this.setString(this.getAsString());else if(e==="number")this.setNumber(this.getAsNumber());else if(e==="boolean")this.setBoolean(this.getAsBoolean());else if(e==="structure"){if(this._type==="structure")return;this._children=this.getAllChildren(),this._type="structure"}else if(e==="array"){if(this._type==="array")return;this._childrenArray=this.getAllChildrenArray(),this._type="array"}}getChild(e){return this._type==="array"?this.getChildAt(Number.isInteger(e)?e:parseInt(e,10)||0):(this._type!=="structure"&&this.castTo("structure"),this.getChildNamed(""+e))}getChildNamed(e){const t=this._children[e];return t??(this._children[e]=new i.Variable)}addChild(e,t){return this._type!=="structure"&&this.castTo("structure"),this._children[e]=t,this}hasChild(e){return this._type==="structure"&&this._children.hasOwnProperty(e)}removeChild(e){this._type==="structure"&&delete this._children[e]}clearChildren(){this._children={},this._childrenArray=[]}replaceChildren(e){this._type="structure",this._children=e}replaceChildrenArray(e){this._type="array",this._childrenArray=e}getAsNumber(){if(this._type!=="number"){let e=0;return this._type==="string"?e=parseFloat(this._str):this._type==="boolean"&&(e=this._bool?1:0),e===e?e:0}return this._value}setNumber(e){this._type="number",e=parseFloat(e),this._value=e===e?e:0}getAsString(){return this._type!=="string"?this._type==="number"?this._value.toString():this._type==="boolean"?this._bool?"true":"false":this._type==="structure"?"[Structure]":this._type==="array"?"[Array]":"":this._str}setString(e){this._type="string",this._str=""+e}getAsNumberOrString(){return this._type==="number"?this._value:this.getAsString()}getAsBoolean(){return this._type!=="boolean"?this._type==="number"?this._value!==0:this._type==="string"?this._str!=="0"&&this._str!==""&&this._str!=="false":!0:this._bool}setBoolean(e){this._type="boolean",this._bool=!!e}toggle(){this.setBoolean(!this.getAsBoolean())}setValue(e){this._type==="string"?this.setString(e):this._type==="number"?this.setNumber(e):this._type==="boolean"&&this.setBoolean(e)}getValue(){return this._type==="number"?this.getAsNumber():this._type==="boolean"?this.getAsBoolean():this.getAsString()}isStructure(){return this._type==="structure"}isNumber(){return this._type==="number"}getType(){return this._type}getAllChildren(){return this._type==="structure"?this._children:this._type==="array"?Object.assign({},this._childrenArray):{}}getAllChildrenArray(){return this._type==="structure"?Object.values(this._children):this._type==="array"?this._childrenArray:[]}getChildrenCount(){return this._type==="structure"?Object.keys(this._children).length:this._type==="array"?this._childrenArray.length:0}add(e){this.setNumber(this.getAsNumber()+e)}sub(e){this.setNumber(this.getAsNumber()-e)}mul(e){this.setNumber(this.getAsNumber()*e)}div(e){this.setNumber(this.getAsNumber()/e)}concatenateString(e){this.setString(this.getAsString()+e)}concatenate(e){this.setString(this.getAsString()+e)}getChildAt(e){return this._type!=="array"&&this.castTo("array"),(this._childrenArray[e]===void 0||this._childrenArray[e]===null)&&(this._childrenArray[e]=new i.Variable),this._childrenArray[e]}removeAtIndex(e){this._type==="array"&&this._childrenArray.splice(e,1)}pushVariableCopy(e){this._type!=="array"&&this.castTo("array"),this._childrenArray.push(e.clone())}_pushVariable(e){this._type!=="array"&&this.castTo("array"),this._childrenArray.push(e)}pushValue(e){this._type!=="array"&&this.castTo("array"),this._childrenArray.push(new i.Variable({type:typeof e,value:e}))}getPlayerOwnership(){return this._playerNumber}setPlayerOwnership(e){this._playerNumber=e}disableSynchronization(){this._playerNumber=null}}i.Variable=l})(gdjs||(gdjs={})); +//# sourceMappingURL=variable.js.map diff --git a/variablescontainer.js b/variablescontainer.js new file mode 100644 index 0000000000000000000000000000000000000000..3b058976efa361ef43308bbc87adbbee35a32df3 --- /dev/null +++ b/variablescontainer.js @@ -0,0 +1,2 @@ +var gdjs;(function(o){const u=class{constructor(r){this._variablesArray=[];this._variables=new Hashtable,r!==void 0&&this.initFrom(r)}initFrom(r,e){e===void 0&&(e=!1),e||(u._deletedVars=u._deletedVars||[],this._variables.keys(u._deletedVars));const a=this;let i=0;for(let t=0;t=this._variablesArray.length){let e=new o.Variable;return this._variables.put("",e),e}else{let e=this._variablesArray[r];return e.isUndefinedInContainer()&&e.reinitialize(),e}}has(r){const e=this._variables.get(r);return!!e&&!e.isUndefinedInContainer()}hasVariable(r){const e=this._variablesArray.find(a=>a===r);return!!e&&!e.isUndefinedInContainer()}getVariableNameInContainerByLoopingThroughAllVariables(r){const e=this._variables.items;for(const a in e)if(e.hasOwnProperty(a)&&e[a]===r)return a;return null}getNetworkSyncData(r){const e=r.playerNumber,a=r.isHost,i=[],t=[];return this._variables.keys(t),t.forEach(n=>{const l=this._variables.get(n),s=l.getPlayerOwnership();if(l.isUndefinedInContainer()||s===null||e!==void 0&&s===0&&!a||s!==0&&e!==s)return;const c=l.getType(),b=c==="structure"||c==="array"?"":l.getValue();i.push({name:n,value:b,type:c,children:this.getStructureNetworkSyncData(l),owner:s})}),i}getStructureNetworkSyncData(r){if(r.getType()==="array"){const e=[];return r.getAllChildrenArray().forEach(a=>{const i=a.getType(),t=i==="structure"||i==="array"?"":a.getValue(),n=a.getPlayerOwnership();a.isUndefinedInContainer()||n===null||e.push({name:"",value:t,type:i,children:this.getStructureNetworkSyncData(a),owner:n})}),e}if(r.getType()==="structure"){const e=r.getAllChildren();if(!e)return;const a=[];return Object.entries(e).forEach(([i,t])=>{const n=t.getType(),l=n==="structure"||n==="array"?"":t.getValue(),s=t.getPlayerOwnership();t.isUndefinedInContainer()||s===null||a.push({name:i,value:l,type:n,children:this.getStructureNetworkSyncData(t),owner:s})}),a}}updateFromNetworkSyncData(r){const e=this;for(let a=0;athis._getVariableDataFromNetworkSyncData(e)):void 0}}};let d=u;d._deletedVars=[],d.badVariablesContainer={_variables:new Hashtable,_variablesArray:[],has:function(){return!1},getFromIndex:function(){return u.badVariable},get:function(){return u.badVariable},remove:function(){},add:function(){},_declare:function(){},initFrom:function(){},getNetworkSyncData:function(){return[]},updateFromNetworkSyncData:function(){},getStructureNetworkSyncData:function(){},_getVariableDataFromNetworkSyncData:function(){return{}},hasVariable:function(){return!1},getVariableNameInContainerByLoopingThroughAllVariables:function(){return""},rebuildIndexFrom:function(){}},d.badVariable={_type:"number",_bool:!1,_children:{},_childrenArray:[],_str:"",_undefinedInContainer:!0,_value:0,_playerNumber:0,fromJSON:()=>o.VariablesContainer.badVariable,toJSObject:()=>0,fromJSObject:()=>o.VariablesContainer.badVariable,reinitialize:()=>{},addChild:()=>o.VariablesContainer.badVariable,castTo:()=>{},clearChildren:()=>{},clone:()=>o.VariablesContainer.badVariable,getChildrenCount:()=>0,replaceChildren:()=>{},replaceChildrenArray:()=>{},getType:function(){return"number"},isPrimitive:function(){return!0},setValue:()=>{},toggle:()=>{},getValue:()=>0,getChild:()=>o.VariablesContainer.badVariable,getChildAt:()=>o.VariablesContainer.badVariable,getChildNamed:()=>o.VariablesContainer.badVariable,hasChild:function(){return!1},isStructure:function(){return!1},isNumber:function(){return!0},removeChild:function(){},setNumber:function(){},setString:function(){},setBoolean:function(){},getAsString:function(){return"0"},getAsNumber:function(){return 0},getAsNumberOrString:function(){return 0},getAsBoolean:function(){return!1},getAllChildren:function(){return{}},getAllChildrenArray:function(){return[]},pushVariableCopy:()=>{},_pushVariable:()=>{},pushValue:()=>{},removeAtIndex:function(){},add:function(){},sub:function(){},mul:function(){},div:function(){},concatenate:function(){},concatenateString:function(){},setUndefinedInContainer:function(){},isUndefinedInContainer:function(){return!0},getPlayerOwnership:function(){return 0},setPlayerOwnership:function(){},disableSynchronization:function(){}},o.VariablesContainer=d})(gdjs||(gdjs={})); +//# sourceMappingURL=variablescontainer.js.map